开发者

LaTeX - Proper vertical spacing on multi-line parboxes with multicols

开发者 https://www.devze.com 2023-01-07 15:46 出处:网络
I\'m trying to get two-column typesetting working, with a list of items. However, that list has elements that are either one or two lines, i.e.

I'm trying to get two-column typesetting working, with a list of items. However, that list has elements that are either one or two lines, i.e.

Alpha
Beta
Zeta
   Alternative: Upsilon      <– (second line of the Zeta)
Gamma
   Alternative: Lambda
Epsilon
Omega
Omicron
   Alternative: Upsilon
...

I'd like to have this list on two columns, however I don't want the list to end with a split of a two-line item (i.e. "Alternative: xyz" should never start the second column).

My first thought is to put two-line elements into a parbox, like this:

\documentclass[12pt]{memoir}
\usepackage{multicol,ragged2e}
\begin{document}

\begin{multicols}{2}
\RaggedRight
Alpha\\
Beta\\
\parbox{\columnwidth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
\parbox{\columnwidth}{ Gamma\\ \hspace{1em} \textit{Alternative:} Lambda }
Epsilon\\
Omega\\
\parbox{\columnwidth}{ Omicron\\ \hspace{1em} \textit{Alternative:} Upsilon }
Kappa\\
\parbox{\columnwi开发者_高级运维dth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
\parbox{\columnwidth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
Alpha\\
Beta\\
\parbox{\columnwidth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
\parbox{\columnwidth}{ Gamma\\ \hspace{1em} \textit{Alternative:} Lambda }
Epsilon\\
Omega\\
\parbox{\columnwidth}{ Omicron\\ \hspace{1em} \textit{Alternative:} Upsilon }
Kappa\\
\parbox{\columnwidth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
\parbox{\columnwidth}{ Zeta\\ \hspace{1em} \textit{Alternative:} Upsilon }
Sigma\\
Delta\\
\end{multicols}
\end{document}

I've made that example longer than necessary to highlight the deficiency of this attempted solution. If you typeset this, the spacing between the elements is uneven, and it looks terrible.

I was wondering, then:

  1. if there were any alternatives to using a \parbox that do not suffer this inconsistent typesetting.

  2. if this \parbox solution could be altered so as to not have the inconsistent spacing between lines.

Thank you for reading.

Brian


1) Define your macros, for example, \colparbox and \Alt.

2) Look the following code.

\def\colparbox#1{\strut \par \vskip -\baselineskip \nointerlineskip
   \parbox{\columnwidth}{\strut\ignorespaces#1\unskip\strut}\par}

\def\Alt{\hspace{1em} \textit{Alternative:} }

\begin{multicols}{2} 
\RaggedRight 
Alpha\\ 
Beta\\ 
\colparbox{ Zeta\\ \Alt Upsilon } 
\colparbox{ Gamma\\ \Alt Lambda } 
Epsilon\\ 
Omega\\ 
\colparbox{ Omicron\\ \Alt Upsilon } 
Kappa\\ 
\colparbox{ Zeta\\ \Alt Upsilon } 
\colparbox{ Zeta\\ \Alt Upsilon } 
Alpha\\ 
Beta\\ 
\colparbox{ Zeta\\ \Alt Upsilon } 
\colparbox{ Gamma\\ \Alt Lambda } 
Epsilon\\ 
Omega\\ 
\colparbox{ Omicron\\ \Alt Upsilon } 
Kappa\\ 
\colparbox{ Zeta\\ \Alt Upsilon } 
\colparbox{ Zeta\\ \Alt Upsilon } 
Sigma\\ 
Delta\\ 
\end{multicols} 
0

精彩评论

暂无评论...
验证码 换一张
取 消