LaTeX:内容自动两列换行

发布于 2024-08-27 03:59:45 字数 370 浏览 7 评论 0原文

假设我有一个单词列表,需要保留其顺序,并且需要排序为两列。

我可以用表格很好地做到这一点:

\begin{tabular}{l l}
abc & def \\
ghi & jkl \\
\end{tabular}

但这样做会使重新排序列表变得相当困难且耗时。

是否可以有一个自动换行的两列列表? 理想情况下,我想简单地输入一个有序列表:

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

并将其包装为两列(如表格所启用):

abc  def
ghi  jkl

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

篱下浅笙歌 2024-09-03 03:59:45

第二次尝试,测试:

\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}

这个版本确实很难看。 tabbing 环境中 \\ 之后的负 vskip 是一件好事。这可以适应在您的“神奇”环境中使用 \\

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.

眼睛会笑 2024-09-03 03:59:45

尝试 multicol 环境。不确定这是否是您想要的,但

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

会将列表包装成两列。我认为你需要 \usepackage{multicol} ,但它可能是 multicols 。我还应该注意,您可以使用 \begin{multicols*}{2} 创建类似的环境,但具有不同的属性: \begin{multicols} 创建列并平等地平衡它们,但是 \begin{multicols*} 创建列并在进入第二个列之前填充第一个列(因此不会总是“平衡”,这对于论文来说更理想)。

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

七堇年 2024-09-03 03:59:45

您可能最好在其他程序中创建表并使用脚本或导出函数将其转换为 LaTeX 表。 longtable 包将允许该表格跨多个页面换行。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文