How to forbid horizontal overflows totally (in some cases)?
"Jairo A. del Rio" <[email protected]>
| Newsgroups | gmane.comp.tex.context |
|---|---|
| Message-ID | <CAKyqqabC7HtLoUi3SatDP0FsQwYv1T7e83Zoc+2+yC+S=YEC+A@mail.gmail.com> |
Hi, I want to know if ConTeXt currently has a simpler mechanism to achieve what is in the title, i.e., avoid text overflows at all. Something similar to "ugly MSWord justify" for some specific cases. I've attached an example of what I need to do and what I've come up with so far (formulas are just for testing, not actual content). Best regards, Jairo ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : [email protected] / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
nooverflow.pdf
(application/pdf, 12.3 KB) - not displayed
nooverflow.tex
(text/x-tex, 995 B)
\startluacode
userdata = userdata or {}
local Examples = {}
local op = {
{"+", function(a,b) return a + b end},
{"-", function(a,b) return a - b end},
{"*", function(a,b) return a * b end}
}
for i = 1, 100 do
local a = math.random(1,1000)
local b = math.random(1,1000)
local curr = op[math.random(1,3)]
local sign = curr[1]
local res = curr[2](a,b)
Examples[i] = string.format("%d%s%d = %d", a, sign, b, res)
end
userdata.Examples = Examples
\stopluacode
\starttext
\scratchtoksone\emptytoks
\dontleavehmode%
\localcontrolledrepeat\numexpr\ctxlua{context(\letterhash userdata.Examples)}\relax%
{\etoks\scratchtokstwo{\ctxlua{context.inframed(userdata.Examples[\the\currentloopiterator])}\hfill}%
\ifdim\wdofstring{\the\scratchtoksone\the\scratchtokstwo\removeunwantedspaces}>\availablehsize
\the\scratchtoksone%\crlf%
\scratchtoksone\emptytoks%
\par\dontleavehmode%
\fi
\etoksapp\scratchtoksone{\the\scratchtokstwo}}%
\the\scratchtoksone
\stoptext