使用表格环境时对齐文本

使用表格环境时对齐文本

我在用着

\documentclass[10pt,twocolumn]{article}

\usepackage{hhline}
\usepackage[left=1cm,right=1cm,top=1cm,bottom=2cm]{geometry}

\addtolength{\columnsep}{0.4cm}
\addtolength{\textwidth}{\columnsep}

\setlength\parindent{0pt}

\begin{document}

\begin{tabular}{ll}
1 & Aron climbed down a narrow gap between  \\
2 & the walls of the canyon. Suddenly a large  \\
3 & rock fell on his right arm. It trapped his arm  \\
4 & against the canyon wall. He tried to pull is  \\
5 & arm out, but the rock weighed 360 kilograms.\\
\end{tabular}

\end{document}

我想让每段长文本的四行都对齐,有什么办法吗?


我添加了一个更完整的示例来展示我想要的内容。

答案1

我假设这就是你想要的,但它最终看起来很糟糕(或者是 MSWord 的 LaTeX 模仿......)

为了给行编号,我刚刚做了一个计数器,这将节省您一些打字时间。对于间距,我使用了Bruno LeFloch 的宏它会分割空格分隔的文本并对其应用宏。然后,我\hfill使用该包将其附加到单元格中的每个单词collectcell。这会用填充行宽所需的空间填充每行。呃。:)

\documentclass[10pt,twocolumn]{article}

\usepackage{array}
\usepackage{collcell}
\usepackage{xparse}
\usepackage{etoolbox}

\ExplSyntaxOn
% This macro based on https://tex.stackexchange.com/a/25704/
\NewDocumentCommand {\hfillspace}
  { > { \SplitList { ~ } } m }
  { \tl_map_inline:nn {#1} { ##1\hfill } }
\ExplSyntaxOff

\newcounter{myline}
\AtBeginEnvironment{tabular}{\setcounter{myline}{0}}

\begin{document}
\begin{tabular}{>{\stepcounter{myline}\themyline\quad\collectcell\hfillspace}p{.9\columnwidth}<{\endcollectcell}}
Aron climbed down a narrow gap between\\
the walls of the canyon. Suddenly a large\\
rock fell on his right arm. It trapped his arm\\
against the canyon wall. He tried to pull is\\
arm out, but the rock weighed 360 kilograms. 
\end{tabular}
\end{document}

在此处输入图片描述

相关内容