Well, I wanted to have a minipage spanning across pages, so first I thought to split a minipage so it can , but I learned you cannot; so I got to breakable vboxes, and in trying that, learned that cannot vsplit a parbox. And now that I can \vsplit a \vbox, turns out I don't know how to align it vertically at top. I tried most common \vtop syntax patterns I could find, and ultimately came to this MWE:
\documentclass{article}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{lua-visual-debug}
\pagecolor{yellow!10}
\begin{document}
\lipsum[1]
\newbox\myshortbox
\setbox\myshortbox=%
\hbox {%to 0.2\textwidth {%
\parbox[t]{0.2\textwidth}{%
\hrule height 0pt width 0pt % ref for utter top alignment
Blah blah blah,
blah blah blah blah blah blah blah,
Blah blah blah blah,
}%
}%
\newbox\mylongbox
\setbox\mylongbox=%
\vbox { %\hbox {%to 0.7\textwidth{%
\hsize=0.7\textwidth
\hrule height 0pt width 0pt % ref for utter top alignment
\lipsum[2-15]
}%
\newbox\myspltbox % do a vsplit
\setbox\myspltbox=\vsplit\mylongbox to 0.5\textheight
\newbox\myvtopbox % align vertically on top
\setbox\myvtopbox=%
% \vtop{\hsize=0.9\textwidth \copy\myshortbox\copy\myspltbox} %
% \box\myvtopbox % with this, below one another!
\vtop{\hsize=0.2\textwidth \copy\myshortbox} %
\newbox\myvtopboxB %
\setbox\myvtopboxB=%
\vtop{\hsize=0.7\textwidth \copy\myspltbox} %
\hbox{\box\myvtopbox \box\myvtopboxB}%
\end{document}
… which results with this output (click for full res):
… whereas I'd like the short box to be vertically aligned on top with the longer split box, instead. Where am I going wrong – and how could I achieve this?
(in earlier tries, I think I saw that two \parbox[t]
s can align with \vtop
– but I cannot vsplit \parbox
es, which is why I did this).
Below I'll dump the code with comments leading to the above MWE — because I've made a ton of wrong assumptions there, which I'd like to refer to again, once I've forgotten all this business about boxes again :)
; hope that's OK:
% http://www.tug.org/utilities/plain/cseq.html#vtop-rp
% https://tex.stackexchange.com/q/3202/minipage-spanning-across-pages
% https://tex.stackexchange.com/questions/36107/how-to-split-a-minipage
% https://tex.stackexchange.com/questions/20901/breakable-vboxes/
% http://stackoverflow.com/q/2034144/latex-how-to-create-boxes-fixed-w
% https://tex.stackexchange.com/q/34166/understanding-minipages-align-top
% https://tex.stackexchange.com/q/58310/top-aligning-text-of-two-parboxes
% https://tex.stackexchange.com/q/46480/setbox-vs-sbox-and-savebox
% https://tex.stackexchange.com/q/187692/why-cannot-i-vsplit-a-parbox
\documentclass{article}
\usepackage{lipsum}
% \usepackage{trace}
\usepackage{lua-visual-debug}
% \usepackage{unravel}
\begin{document}
\lipsum[1]
% "minipage environment because it guarantees that the text contained doesn't span pages"
% "rather the two pieces of the typeset minipage into two box registers."
% "However this can't be done with minipage, but only with lower level commands: \vbox and \vsplit."
% "A \vtop is indecomposable. TeX will not split it between two pages [93]."
% "A \box command adds the contents of the box to the current list, and it empties the box; The \copy command is similar to \box except \copy does not empty the box; Plain TeX has a \newbox command which reserves a box for a special purpose"
% "THE \setbox command puts material in a box register (\box0 to \box255). Box registers are local to a group. A box register is either void or it contains an \hbox, \vbox, or \vtop. Once material is placed in a box, it may be typeset or moved by \box, \copy, \vsplit, or one of the unbox commands"
% \begingroup\setbox0\vbox\bgroup
% % % \traceon
% % % \unravel{\bgroup
% % \begin{minipage}[t]{0.2\textwidth}
% % Blah blah blah,
% % blah blah blah blah blah blah blah,
% % Blah blah blah blah,
% % \end{minipage}
% % % \egroup}
% % \begin{minipage}[t]{0.7\textwidth}
% % \lipsum[2-15]
% % \end{minipage}
% % % \traceoff
% % \vbox {% minipage[t]
% % % \hbox to 0.2\textwidth{% does not break text
% % \parbox{0.2\textwidth}{%
% % Blah blah blah,
% % blah blah blah blah blah blah blah,
% % Blah blah blah blah,
% % }%
% % }
% % \vbox {% minipage[t]
% % \parbox{0.7\textwidth}{%
% % \lipsum[2-15]
% % }%
% % }
% \egroup
% \typeout{\the\ht0,\the\textheight} % minipage 6.94444pt,550.0pt ; vtop, vbox: 1054.83333pt,550.0pt
% \ifdim\ht0>0.5\textheight
% \typeout{'ERE}
% \setbox1\vsplit0 to 0.5\textheight
% \vtop{\unvbox1}
% \fi
% \vtop{\unvbox0}
% \endgroup
% \hbox{A} % left edge of page - not at parindent!
% "\setbox is the underlying TeX primitive so it does not read its arguments as a normal macro"; \parbox is LaTex2e
% "\sbox\boxa{aa} is like \setbox\boxa\hbox{....} so it supplies the \hbox"
% without the hbox with setbox here: "! A <box> was supposed to be here."
% can do without (\hbox) "to 0.2\textwidth"; parbox sets it
\newbox\myshortbox
% \setbox10=%
\setbox\myshortbox=%
\hbox {%to 0.2\textwidth{%
\parbox[t]{0.2\textwidth}{%
\hrule height 0pt width 0pt % ref for utter top alignment
Blah blah blah,
blah blah blah blah blah blah blah,
Blah blah blah blah,
}%
}%
%
% \setbox\myshortbox=%
% % \hbox to 0.2\textwidth{ % doesn't break lines at all! regardless of \hsize; needs \vrule
% % \vrule height 0pt width 0pt % ref for utter top alignment
% \vbox { % \vbox{\hsize - text breaking not really good
% \hsize=0.2\textwidth
% \hrule height 0pt width 0pt % ref for utter top alignment
% Blah blah blah,
% blah blah blah blah blah blah blah,
% Blah blah blah blah,
% }%
% %
% NOTE: the long vboxes have a longer depth than height!
% NOTE: sizes of box registers dissapear as soon as another setbox kicks in!:
% \typeout{10: \the\ht10, \the\dp10; \the\textheight}
\typeout{10: \the\ht\myshortbox, \the\dp\myshortbox; \the\textheight}
% 10: 6.94444pt, 49.94444pt; 550.0pt
\newbox\mylongbox
% \setbox11=%
\setbox\mylongbox=%
% if I use only hbox, or vbox{hbox, boxes will stick to the left margin
% if I use only vbox, or \vbox {\hsize=0.7\textwidth, then boxes indent with \parindent
\vbox { %\hbox {%to 0.7\textwidth{%
%\parbox[t]{0.7\textwidth}{% cannot \vsplit parbox
\hsize=0.7\textwidth
\hrule height 0pt width 0pt % ref for utter top alignment
% \lipsum[2]
\lipsum[2-15]
}%
%}%}%
% \copy11 % typesets!
% \copy\mylongbox
% \typeout{10: \the\ht10, \the\dp10; 11: \the\ht11, \the\dp11; \the\textheight}
\typeout{10: \the\ht\myshortbox, \the\dp\myshortbox; 11: \the\ht\mylongbox, \the\dp\mylongbox; \the\textheight}
% 10: 0.0pt, 0.0pt; 11: 6.94444pt, 120.0pt; 550.0pt
% 10: 0.0pt, 0.0pt; 11: 6.94444pt, 1981.94444pt; 550.0pt
% if we want to split, probably should do it here:
%\global\splittopskip=0pt
%\splitmaxdepth=0.5\textheight
\newbox\myspltbox
% \setbox12=\vsplit11 to 0.5\textheight
% \setbox12=\vsplit\mylongbox to 0.5\textheight
\setbox\myspltbox=\vsplit\mylongbox to 0.5\textheight
% 10: 0.0pt, 0.0pt; 11: 0.0pt, 0.0pt; 12: 275.0pt, 1981.94444pt; 550.0pt % without splitmaxdepth
% 10: 0.0pt, 0.0pt; 11: 0.0pt, 0.0pt; 12: 275.0pt, 275.0pt; 550.0pt % with splitmaxdepth
% \copy11
% \copy\mylongbox
% \typeout{10: \the\ht10, \the\dp10; 11: \the\ht11, \the\dp11; 12: \the\ht12, \the\dp12; \the\textheight}
\typeout{10: \the\ht\myshortbox, \the\dp\myshortbox; 11: \the\ht\mylongbox, \the\dp\mylongbox; 12: \the\ht\myspltbox, \the\dp\myspltbox; \the\textheight}
% 10: 0.0pt, 0.0pt; 11: 0.0pt, 0.0pt; 12: 275.0pt, 275.0pt; 550.0pt
% \setbox13=\vtop{\hsize=0.9\textwidth \box10\box11} % nothing if splitting
% \typeout{10: \the\ht10, \the\dp10; 11: \the\ht11, \the\dp11; 13: \the\ht13, \the\dp13; \the\textheight}
\typeout{10: \the\ht\myshortbox, \the\dp\myshortbox; 11: \the\ht\mylongbox, \the\dp\mylongbox; 13: \the\ht\myvtopbox, \the\dp\myvtopbox; \the\textheight}
% 10: 0.0pt, 0.0pt; 11: 0.0pt, 0.0pt; 13: 6.94444pt, 120.0pt; 550.0pt
% note: two refs to box10 are not typeset twice! unless \copy is used (because \box is emptied after use)
% \unvbox13 % does not break from last paragraph
% \hbox{\box10\box13} % breaks from last paragraph
\vbox{ \box\myshortbox\box\myvtopbox} % breaks from last paragraph
\end{document}
% \@iminipage [t]{0.2\textwidth }
% \@iiiminipage {t}\relax [s]{0.2\textwidth }
% [===== Step 76 =====] \@iiiminipage = macro:#1#2[#3]#4->\leavevmode \...
% <| {\begingroup
% ||
% |> \leavevmode \@pboxswfalse \setlength \@tempdima {0.2\textwidth }\def
% |> \@mpargs {{t}{\relax }[s]{0.2\textwidth }}\setbox \@tempboxa \vbox \bgroup
% |> \color@begingroup \hsize \@tempdima \textwidth \hsize \columnwidth \hsize
% |> \@parboxrestore \def \@mpfn {mpfootnote}\def \thempfn {\thempfootnot...
% [===== Step 77 =====] \leavevmode = macro:->\unhbox \voidb@x
% [===== Step 78 =====] \unhbox = \unhbox : \everypar={}
% [===== Step 91 =====] \textwidth = \dimen80= 345.0pt
% [===== Step 92 =====] Set \@tempdima(\dimen14)=68.99895pt
% [===== Step 94 =====] \def \@mpargs {{t}{\relax }[s]{0.2\textwidth }}
% [===== Step 95 =====] Set \@mpargs=macro:->{t}{\relax }[s]{0.2\textwi...
% <| {\begingroup
% ||
% |> \setbox \@tempboxa \vbox \bgroup \color@begingroup \hsize \@tempdima
% |> \textwidth \hsize \columnwidth \hsize \@parboxrestore \def \@mpfn
% |> {mpfootnote}\def \thempfn {\thempfootnote }\c@mpfootnote \z@ \let
% |> \@footnotetext \@mpfootnotetext \let \@listdepth \@mplistdepth
% [===== Step 99 =====] \setbox 12=\vbox {
% [===== Step 314 =====] back_input: \expandafter \@iiiparbox
% <| {\begingroup \setbox 12=\vbox {Blah blah blah, blah blah blah blah blah
% <| blah blah, Blah blah blah blah, \par }
% ||
% |> \@iiiparbox {t}{\relax }[s]{0.2\textwidth }{\unvbox \@tempboxa
% |> }\@checkend {minipage}\expandafter \endgroup \if@endpe \@doendpe \fi
% |> \if@ignore \@ignorefalse \ignorespaces \fi \egroup
% [===== Step 315 =====] \@iiiparbox = \long macro:#1#2[#3]#4#5->\leavev...
% <| {\begingroup \setbox 12=\vbox {Blah blah blah, blah blah blah blah blah
% <| blah blah, Blah blah blah blah, \par }
% ||
% |> \leavevmode \@pboxswfalse \setlength \@tempdima {0.2\textwidth
% |> }\@begin@tempboxa \vbox {\hsize \@tempdima \@parboxrestore \unvbox
% |> \@tempboxa \@@par }\ifx \relax \relax \else \setlength \@tempdimb {\relax
% |> }\edef \@parboxto {to\the \@tempdimb }\fi \if tb\vbox \else \if tt\vtop
% |> \else \ifm... (284 chars)
% [===== Step 494 =====] \egroup = end-group character }
% <| {\begingroup \setbox 12=\vbox {Blah blah blah, blah blah blah blah blah
% <| blah blah, Blah blah blah blah, \par }\begingroup \setbox 12=\vbox {\par
% <| }\vtop {}\@end@tempboxa \endgroup }
% ||
% |>
% [===== The end! =====]
Best Answer
Is this something similar to what you'd like to get?