开发者

LaTeX: Automatic two-column wrapping of content

开发者 https://www.devze.com 2022-12-25 08:00 出处:网络
Say I have a list of words that need to retain their order, and need to be sorted into two columns. I can do this rather well with a tabular:

Say I have a list of words that need to retain their order, and need to be sorted into two columns.

I can do this rather well with a tabular:

\begin{tabular}{l l}开发者_高级运维
abc & def \\
ghi & jkl \\
\end{tabular}

But doing so makes it rather difficult and time consuming to reorder the list.

Is it possible to have an automatically wrapped two-column list? Ideally, I would like to simply enter an ordered list:

\begin{magic}
abc \\
def \\
ghi \\
jkl \\
\end{magic}

And have it wrapped to two columns (as the tabular enables):

abc  def
ghi  jkl


Second attempt, tested:

\def\word{\let\word\rightword \message{First}}
\def\leftword{\\ \let\word\rightword \message{Left}}
\def\rightword{\> \let\word\leftword \message{Right}}
\begin{tabbing}
\hskip 3in \=\\
% Items
\word One
\word Two
\word Three
\end{tabbing}

This version is indeed ugly. A negative vskip after the \\ in the tabbing env would be a good thing. This can be adapted to use the \\s in your 'magic' environment.


Try the multicol environment. Not sure if this is what you want, but

\begin{multicols}{2}
\begin{itemize}
\item abc
\item def
% etc
\end{itemize}
\end{multicols}

will wrap the list into two cols. You need to \usepackage{multicol} i think, but it might be multicols. I should also note that you can use \begin{multicols*}{2} to create similar environment, but with a different property: \begin{multicols} creates columns and balances them equally, but \begin{multicols*} creates columns and fills the first before going to the second (so won't always be 'balanced', which is more ideal for papers).


You might be better off with creating the table in some other program and using a script or export function to convert it to a LaTeX table. The longtable package will allow that table to wrap across multiple pages.

0

精彩评论

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

关注公众号