![如何将行的一部分缩进到一定量?](https://linux22.com/image/257907/%E5%A6%82%E4%BD%95%E5%B0%86%E8%A1%8C%E7%9A%84%E4%B8%80%E9%83%A8%E5%88%86%E7%BC%A9%E8%BF%9B%E5%88%B0%E4%B8%80%E5%AE%9A%E9%87%8F%EF%BC%9F.png)
如果这是一个基本问题,我很抱歉,但是我对 LaTeX 和排版还不熟悉,我不确定如何正确表达我的问题。
我有一份如下所示的文档:
\documentclass[12pt,letterpaper]{article}
\usepackage[margin=0.7in]{geometry}
\usepackage[parfill]{parskip}
\newenvironment{question}[1]
{\par\bfseries#1.\ignorespaces}
{\par\ignorespacesafterend}
\newenvironment{answer}
{\par\leftskip=2.0em\ignorespaces}
{\par\ignorespacesafterend}
\begin{document}
\begin{question}{1}
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}
\begin{question}{3}
Test test
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}
\end{document}
如何修改我的question
环境,以便数字后的第一行缩进到与answer
环境内的文本相同的级别?我不希望数字缩进,但我希望它后面的行(但不是后续行)缩进到与 lorem ipsum 文本相同的级别。
补充一下,我只能借助图片来描述我的问题。用文字解释它正确的方法是什么?
答案1
您可以将数字放在所需宽度的框内:
\documentclass[12pt,letterpaper]{article}
\usepackage[margin=0.7in]{geometry}
\usepackage[parfill]{parskip}
\newlength\ansindent
\setlength\ansindent{2em}
\newenvironment{question}[1]
{\par\bfseries\makebox[\ansindent][l]{#1.}\ignorespaces}
{\par\ignorespacesafterend}
\newenvironment{answer}
{\par\leftskip=\ansindent}
{\par\ignorespacesafterend}
\begin{document}
\begin{question}{1}
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
Testing testing testing testing testing testing testing testing testing
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}
\begin{question}{3}
Test test
\end{question}
\begin{answer}
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
\end{answer}
\end{document}