Skip to content
Snippets Groups Projects

Generování protokolů a zpracování scanů

Merged Martin Mareš requested to merge mj/protokoly into devel
2 files
+ 38
1
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 37
1
@@ -23,7 +23,43 @@
\def\kolo{TODO}
\def\kat{TODO}
\def\field#1#2{\hbox to #1{#2\hss}}
\newbox\ellipsisbox
\setbox\ellipsisbox=\hbox{\bf~\dots~~}
\directlua{
function cut_box(box_nr, max_w)
local box = tex.box[box_nr]
% nodetree.analyze(box)
local n
local total_w = 0
local last_visible
for n in node.traverse(box.head) do
local w, h, d = node.dimensions(n, n.next)
total_w = total_w + w
if total_w > max_w then
local new = node.copy_list(box.head, last_visible.next)
tex.box[box_nr] = node.hpack(new)
% nodetree.analyze(tex.box[box_nr])
return
end
if n.id == 0 or n.id == 2 or n.id == 29 then % hlist, rule, glyph
last_visible = n
end
end
end
}
\def\limitedbox#1#2{%
\setbox0=\hbox{#2}%
\ifdim \wd0 > #1\relax
\dimen0=\dimexpr #1 - \wd\ellipsisbox\relax
\directlua{cut_box(0, tex.dimen[0])}%
\setbox0=\hbox{\box0\copy\ellipsisbox}%
\fi
\box0
}
\def\field#1#2{\hbox to #1{\limitedbox{#1}{#2}\hss}}
\def\fillin#1{\smash{\lower 2pt\hbox to #1{\hrulefill}}}
% \proto{kód}{jméno}{třída}{škola}{příklad}
Loading