水平对齐多列中的文本

水平对齐多列中的文本

我想实现这样的目标,

1. Question One             The answer to the question.

2. Question Two             The answer to the question
                            that can span across multiple
                            lines because it is long.

3. Sometimes the question   Only one line answer
   can span across multi-
   ple line but have one
   answer.

4. Sometimes the question   The answers can also have
   can have multiple        multiple lines and one thing
   lines.                   notice is that there is
                            enumeration as well.

我尝试了multicol、、环境tabbingmultienum但无法做到这一点。

答案1

在第一列开头自动进行问题计数的建议。

\documentclass{article}

\newcounter{questioncnt}

\usepackage{array}

\newcolumntype{N}[1]{>{\raggedleft\stepcounter{questioncnt}\thequestioncnt.\arraybackslash}m{#1}}

\usepackage{blindtext}

\begin{document}

\begin{tabular}{N{2cm}p{5cm}p{6cm}}
  & \blindtext & \blindtext \tabularnewline
  & \blindtext & \blindtext \tabularnewline
\end{tabular}

\end{document}

另一个例子:

\documentclass{article}

\newcounter{questioncnt}
\usepackage{array}

\newcolumntype{N}[1]{>{\raggedleft\stepcounter{questioncnt}\thequestioncnt.\arraybackslash}R{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\usepackage{blindtext}

\begin{document}


\begin{tabular}{N{2cm}L{6cm}L{6cm}}
  & What is the meaning of life? & foo \tabularnewline
  & What is the answer to any question in the universe? & Of course, there is only one answer and the answer can only be \huge 42 \tabularnewline
\end{tabular}

\end{document}

相关内容