将文本对齐到冒号下方

将文本对齐到冒号下方

用纯文本来说,这就是我想要做的:

Explanation: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend.
             Praesent sed orci commodo, venenatis neque vel, pulvinar velit.
             Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.

更新

如果hspace{5cm}适合单词“解释:”的长度并且如果hspace在枚举环境中工作,那么我希望我的文档看起来像这样:

\documentclass[11pt]{article}

\begin{document}

\begin{enumerate}

\item 1

answer

\item 2

explanation: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend.\\ \hspace {5cm}Praesent sed orci commodo, venenatis neque vel, pulvinar velit.\\ \hspace {5cm}Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.

\item 3

answer

\end{enumerate}

\end{document}

基本上,想象一下

Explanation: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend.
             Praesent sed orci commodo, venenatis neque vel, pulvinar velit.
             Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.

处于枚举环境中。

这就是我要的:

图片

答案1

根据修改后的问题修改答案。有很多方法可以解决难题。以下两种方法可能会给您一些启发。

\documentclass{article}
\usepackage{hanging}
\usepackage{longtable}
\newlength{\hangwidth}
\newcommand{\newhang}[1]{\settowidth{\hangwidth}{#1}\par\hangpara{\hangwidth}{1}#1}
\newcounter{myquestion}

\begin{document}
\stepcounter{myquestion} 
\newhang{\arabic{myquestion}. Question: }What is the question?
\newhang{Answer: }Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\Phasellus volutpat eu orci vitae eleifend.\\Praesent sed orci commodo, venenatis neque vel, pulvinar velit.\\Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.
\stepcounter{myquestion} 
\newhang{\arabic{myquestion}. Question: }What is the question?
\newhang{Answer: }Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\Phasellus volutpat eu orci vitae eleifend.\\Praesent sed orci commodo, venenatis neque vel, pulvinar velit.\\Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.
\stepcounter{myquestion} 
\newhang{\arabic{myquestion}. Question: }What is the question?
\newhang{Answer: }Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\Phasellus volutpat eu orci vitae eleifend.\\Praesent sed orci commodo, venenatis neque vel, pulvinar velit.\\Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.

\setcounter{myquestion}{0}
\begin{longtable}{rp{0.7\textwidth}}
\stepcounter{myquestion}\arabic{myquestion}. Question: &What is the question?\\
Answer: &Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend. Praesent sed orci commodo, venenatis neque vel, pulvinar velit. Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.\\
\stepcounter{myquestion}\arabic{myquestion}. Question: &What is the question?\\
Answer: &Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend. Praesent sed orci commodo, venenatis neque vel, pulvinar velit. Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.\\
\stepcounter{myquestion}\arabic{myquestion}. Question: &What is the question?\\
Answer: &Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus volutpat eu orci vitae eleifend. Praesent sed orci commodo, venenatis neque vel, pulvinar velit. Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis nisl dapibus.\\
\stepcounter{myquestion}\arabic{myquestion}. Question: &What is the question?\\
\end{longtable}

\end{document}

在此处输入图片描述

答案2

实现此目的的一种快速而又简单的方法是使用它phantom产生的空间相当于其参数未被phantom'd 的空间量。

\begin{enumerate}
  \item Question\\
  explanation: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus.\\
  \phantom{explanation:} Praesent sed orci commodo.\\
  \phantom{explanation:} Mauris ullamcorper tellus sed quam pellentesque, vitae sagittis.
\end{enumerate}

给我(在 Beamer 中):

在此处输入图片描述

相关内容