Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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):

test04a.png

... 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 \parboxes, 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
% http://tex.stackexchange.com/q/3202/minipage-spanning-across-pages
% http://tex.stackexchange.com/questions/36107/how-to-split-a-minipage
% http://tex.stackexchange.com/questions/20901/breakable-vboxes/
% http://stackoverflow.com/q/2034144/latex-how-to-create-boxes-fixed-w
% http://tex.stackexchange.com/q/34166/understanding-minipages-align-top
% http://tex.stackexchange.com/q/58310/top-aligning-text-of-two-parboxes
% http://tex.stackexchange.com/q/46480/setbox-vs-sbox-and-savebox
% http://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! =====]
share|improve this question
1  
Are you interested in a tcolorbox solution? –  Harish Kumar Jul 3 at 0:08
    
Thanks, @HarishKumar - not for the current project, but I'm sure myself and others may find it useful in the future, so feel free to post; cheers! –  sdaau Jul 3 at 1:26

4 Answers 4

up vote 5 down vote accepted

Is this something similar to what you'd like to get?

\documentclass{article}
\usepackage{microtype}
\usepackage{kantlipsum}

\begin{document}
\kant[1]

\newbox\mylongbox
\setbox\mylongbox=\vbox{
   \hsize=0.7\textwidth
   \kant[2-4]
}

\noindent\parbox[t]{0.2\textwidth}{%
   Blah blah blah,
   blah blah blah blah blah blah blah,
   Blah blah blah blah,
}%
\newbox\myspltbox % do a vsplit
\setbox\myspltbox=\vsplit\mylongbox to 0.5\textheight
\hskip0.1\textwidth\vtop{\unvbox\myspltbox}

\moveright0.3\textwidth\box\mylongbox

\end{document}

enter image description here

share|improve this answer
    
Indeed it is, @egreg - many thanks for that! Cheers! –  sdaau Jul 2 at 23:03
1  
@sdaau But you probably don't need \vsplit at all. –  egreg Jul 3 at 8:01

Using tcolorbox. This is breakable across pages and all the benefits of tikz and tcolorbox like borders, background colour etc can be exploited.

\documentclass{article}
\usepackage{xcolor}
\usepackage{kantlipsum}
\usepackage[many]{tcolorbox}

%% splitbox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{splitbox}[1][]{
    colback=white,
    left=0.5ex,
    top=0pt,
    arc=0pt,
    outer arc=0pt,
    enlarge left by=0.25\textwidth,
    enlarge right by=-\dimexpr0.25\textwidth+\parindent\relax,
    right=\dimexpr0.25\textwidth+\parindent\relax,
    leftrule=0pt,
    rightrule=0pt,
    toprule=0pt,
    bottomrule=0pt,
    breakable,
    nobeforeafter,
    enhanced jigsaw,
    overlay unbroken and first={
      \node[anchor=north east,inner ysep=0pt,align=left,text width=0.245\textwidth]
        at ([yshift=-0.55ex]frame.north west) {#1};
    },
    before=\vskip2\itemsep\noindent
  }

\begin{document}
\kant[1]

\begin{splitbox}[%
   Blah blah blah,
   blah blah blah blah blah blah,
   Blah blah blah blah blah,
   ]%
\kant[2-4]
\end{splitbox}

\end{document}

enter image description here

share|improve this answer
    
Many thanks, @HarishKumar - well, I must admit, I had no idea tcolorbox was tikz related; now I'm even happier you posted this answer :) - cheers! –  sdaau Jul 3 at 11:19

Most asymmetric two column layouts are best handled by a list environment.

enter image description here

This allows page breaking to occur naturally in the main flow without having to guess where to vsplit it. Although if there is a possibility of a page break happening in the first few rows you should need to work a bit harder to prevent that or the hanging parbox will overprint the page foot.

\documentclass{article}
\usepackage{microtype}
\usepackage{kantlipsum}

\newenvironment{foo}
              {\list{}{\leftmargin.3\textwidth}%
               \labelwidth.2\textwidth
               \labelsep.1\textwidth
               \def\makelabel##1{\smash{\parbox[t]{.2\textwidth}{##1}}\hfill}%
               }
               {\endlist}

\begin{document}
\kant[1]

\begin{foo}
\item[Blah blah blah,
   blah blah blah blah blah blah blah,
   Blah blah blah blah]
\kant[2-4]
\end{foo}

\end{document}
share|improve this answer
1  
I was going to add this (see comments to my answer) so I'm glad I don't have to do it. ;-) –  egreg Jul 3 at 8:27
1  
@egreg thought you might which was why I stole your example, and jumped in quick, hopefully I can steal the tick from you:-) –  David Carlisle Jul 3 at 8:30
    
Thanks for that, @DavidCarlisle - great to have this approach, too; cheers! –  sdaau Jul 3 at 11:17

I think I got to a workaround; all that needs to be changed in the above MWE is that this code:

\setbox\myvtopboxB=%
  \vtop{\hsize=0.7\textwidth \copy\myspltbox} %

... needs to be changed to this:

\setbox\myvtopboxB=%
  \vtop{
    \hsize=0.7\textwidth 
    \hrule height 0pt width 0pt 
    \copy\myspltbox
  }

Basically, those rules are used since I read elsewhere on this site, that they can be used as a reference for a "total" vertical top alignment (instead of at baseline of first line of text), if they are put first in a vbox. And with that, I get the desired output:

test04b.png

Anyways - thanks to the lua-visual-debug output, I could see a big box, apparently started for both elements, and it looked to me like the short box is missing a \vfil on the bottom. So I tried inserting a \vfil everywhere, and it did not change a thing - until I noticed these references again, and tried inserting them in boxes - and eventually, this one worked.

So, it would still be nice, if someone knowledgeable could eventually provide a more erudite comment on this.....

share|improve this answer
1  
you want baseline alignment don't you? as it is the alignment is affected by the size of the the letters on the first line, as your image shows, you are out of alignment, with the Blah boz aligned on the top of B –  David Carlisle Jul 3 at 8:09
    
@DavidCarlisle - indeed, eventually it turned out I did want a baseline :) But I think it is good the question is formulated like this, because I've seen many posts about, say, vertical top alignment of images, where something like this would be needed; so I think it is nice with an example with how text behaves in that way. Cheers! –  sdaau Jul 3 at 11:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.