表格完全水平对齐

表格完全水平对齐

我想要表格输出确切地如图所示(单词的位置很重要)。前三行应完全对齐(左右),最后一行应左对齐。我正在寻找一个可以在不同示例中重现的答案,而不是严格仅适用于此示例。重申一下,重要的是单词的位置,而不是外观(字体等)。

例子: 它应该是什么样子

梅威瑟:

\documentclass{article}
\begin{document}

\begin{tabular}{p{8.5cm} l}
You grow emotionally involved. You get to know & relationship \\
this child so intimately that you grow close to the child & involved \\
and you know you despair, you're frustrated. You feel \\
angry - I feel anger a lot of the time. & emotions
\end{tabular}
\end{document}

这是我得到的: mwe 输出

答案1

\documentclass{article}
\usepackage{array}
\begin{document}

\begin{tabular}{@{}>{\parfillskip=0pt}p{8.5cm} l}
You grow emotionally involved. You get to know & relationship \\
this child so intimately that you grow close to the child & involved \\
and you know you despair, you're frustrated. You feel \\
angry -- I feel anger a lot of the time.\hfill\mbox{}& emotions
\end{tabular}
\end{document}

答案2

(在原帖作者澄清说,重现跨行单词的准确位置至关重要之后,我修改了这个答案。)

我建议您使用tabularx具有两列的环境;左侧列应为p{8.5cm},第二列应为 类型X(以占用剩余的可用宽度)。接下来,不要在左侧列中使用换行符,并使用\newline在右侧列中创建所需的换行符。最后,如果需要进行任何微调,请使用“连接线”,即不可中断的空格,以抑制不必要的换行符。对于手头的示例,唯一需要的连接线是 和 之间thischild因此,this child用替换this~child

在此处输入图片描述

\documentclass{article}
\usepackage{tabularx}  % for "tabularx" environment
\usepackage{newpxtext} % optional, for Palatino clone text font
\begin{document}

\noindent
\begin{tabularx}{\textwidth}{@{}
    >{\sloppy\frenchspacing}p{8.5cm} 
    @{\qquad} X@{}}
You grow emotionally involved. You get to know
this~child so intimately that you grow close to the child
and you know you despair, you're frustrated. You feel
angry -- I feel anger a lot of the time.
&
relationship \newline involved \newline\newline emotions \\
\end{tabularx}
\end{document}

答案3

您确定要一张桌子吗?

\documentclass{article}
\usepackage[rmargin=4in]{geometry}
\begin{document}

You grow emotionally involved\marginpar{relationship involved}. You get to know this child so intimately that you grow close to the child and you know you despair, you're frustrated. You feel angry - I feel anger\marginpar{emotions} a lot of the time.

\end{document}

相关内容