表格段落垂直对齐

表格段落垂直对齐

如何制作这种带标签的段落:3 列 2cm 10cm 2cm,最后一列右对齐,其内容从第二列段落的最后一行开始。

10.      Some text or description here 
         can has more than one line           300

这是我目前所拥有的:

\documentclass[10pt,a4paper]{report}
\begin{document}
\begin{tabular}{p{2cm}p{10cm}p{2cm}}
10. &
Some text or description here can has more than one line &
\raggedleft{300} \\
\end{tabular}
\end{document}

我不知道如何垂直对齐最后一列

答案1

最简单的方法可能是将最后一部分设为主要段落的一部分,这样它自然就会与最后一行对齐。具体如何做到这一点取决于它是否需要多行,但例如

在此处输入图片描述

\documentclass[10pt,a4paper]{report}
\setlength\textwidth{16cm}
\begin{document}
\begin{tabular}{p{2cm}p{10cm}p{2cm}}
10. &
Some text or description here can has more than one line 
Some text or description here can has more than one line 
\hfill 300\hspace{-2cm}\mbox{}\\
\end{tabular}
\end{document}

答案2

这看起来很像目录条目。

我发现将其视为一个居中(块)段落更容易,其中第一个元素向左突出,最后一个元素向右突出。我还发现将其编码为分隔的宏(纯样式)更容易。这是一个经受住了时间考验的定义。

\documentclass[12pt]{report}
\newdimen{\mylistindent}
\setlength\mylistindent{2cm}
\def\listline #1\\#2\\#3\par{%
  \begingroup
    \rightskip\mylistindent
    \noindent\hangindent\mylistindent
    \hbox to\mylistindent{\ignorespaces #1\hfil}%
    \ignorespaces #2\hfill\rlap{\kern\mylistindent\llap{#3\unskip}}%
    \par
  \endgroup
}

\pagestyle{empty}
\begin{document}

\listline 10\\
   Some text or description here can have more than one line.
   Some text or description here can have more than one line.\\
   200
\par

\noindent Here is some more text that is more than one line to
show that the formatted line stretches out to both margins.

\end{document}

示例代码的输出

相关内容