首页 > 解决方案 > 在 LaTeX 中布局平行列?

问题描述

我正在寻求按如下方式布局段落: 1. 在引言中,我将在所有列中都有段落。2.然后沿着两个相反意见的专栏并列。它与两列布局的不同之处在于两列将是平行的,并且左侧的内容将始终保留在左侧,而右侧的内容将始终在多个页面的右侧。即使左列的参数数量较短,右列的参数也不应该浮动到左列。

这是 HTML 中的示例: https://www.biblegateway.com/passage/?search=1+Corinthians+15&version=CCB;KJ21 用于比较不同的翻译。

下面是我尝试达到的效果。

\documentclass{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.

\blindtext

\begin{minipage}[t]{0.5\textwidth}
  \section{Argument on the Left}
  Because I am on the left, so must I be not right?

\end{minipage}\begin{minipage}[t]{0.5\textwidth}
  \section{Argument on the Right}
  Because I am on the right, so I must be right!

  \blindtext
\end{minipage}
\end{document}

几乎达到了效果,只是两根柱子之间没有缝隙。

这是结果的屏幕截图: 在此处输入图像描述

什么是更好的解决方案?

如何在 org 模式下通过导出到 PDF(通过 LaTex)实现相同的效果?

标签: latexorg-mode

解决方案


要分隔列,使用较小的 minipages 并在它们之间添加空间就足够了。Minipages 是盒子,你可以使用固定的空间(用~~~ 或\hspace{}),但更好的是橡胶空间\hfill。

\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.

\blindtext

\noindent\begin{minipage}[t]{0.48\textwidth}
  \section{Argument on the Left}
  Because I am on the left, so must I be not right?
\end{minipage}%
\hfill%
\begin{minipage}[t]{0.48\textwidth}
  \section{Argument on the Right}
  Because I am on the right, so I must be right!

  \blindtext
\end{minipage}
\end{document}

在此处输入图像描述

\noindent避免了正常的段落间距并\hfill“将 minipage 推向左右边距。

但这不是最好的解决方案。您将无法正确管理分页符,并且有一个特定的软件包可以完全按照您的意愿行事。

该包paracol定义了一个具有 2 个(或更多)列的并行环境,并提供了一种通过在 cols 之间切换来“同步”它们的方法。它负责分页,绝对是您想要的。

这是 paracol 的示例

\documentclass{report}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{paracol}
\begin{document}
\section{Introduction}
Here are the normal paragraph crossing colmuns.

\blindtext

\begin{paracol}{2}
  \section{Argument on the\\ Left}
  Because I am on the left, so must I be not right?

  \switchcolumn
  \section{Argument on the\\ Right}
  Because I am on the right, so I must be right!

  \blindtext
\end{paracol}
\end{document}

在此处输入图像描述

如您所见,各列之间的部分编号是一致的,但如果您不喜欢,有很多方法可以自定义包。查看文档 另请注意,我必须添加手动换行符以正确格式化节标题,但这是一个小缺点。

关于 org-mode,我使用它,但我没有导出经验,无法真正帮助您。但是借助 paracol 的灵活性,您可以找到一些方法来定义满足您需要的宏。也许如果您提供 org-mode 导出,人们可以尝试找到解决方案。


推荐阅读