我正在定义一个比页面其余部分进一步缩进的环境。
这是我目前的文档:
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\newenvironment{question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{subq}[1]{\begin{trivlist}
\setlength\leftmargin{6cm}
\item[{\bfseries #1.}]}
{\end{trivlist}}
\begin{document}
\title{Title}
\author{Author}
\maketitle
\begin{question}{6}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{question}
\begin{subq}{a}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{subq}
\end{document}
我期望这会使 subq 缩进 6cm,但事实并非如此。它与其他所有内容完全对齐,除了A。左边是几个额外的点。我尝试用leftmargin
和替换parindent
,但leftmargini
没有效果。
我也尝试过leftmargin
在 之前移动\begin{trivlist}
,就像这样:
\newenvironment{subq}[1]{\setlength\leftmargin{10cm} \begin{trivlist}
\item[{\bfseries #1.}]}
{\end{trivlist}}
这给了我完全相同的输出。
有什么建议么?
答案1
您几乎已经完成了,但设置还不够简单trivlist
,您想使用list
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb}
\newenvironment{question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
\newenvironment{subq}[1]{\begin{list}{}{%
\setlength\leftmargin{6cm}}%
\item[{\bfseries #1.}]}
{\end{list}}
\begin{document}
\title{Title}
\author{Author}
\maketitle
\noindent X\dotfill X
\begin{question}{6}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{question}
\begin{subq}{a}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{subq}
\end{document}
答案2
尝试使用低级\parshape
命令。我问的问题几周前解释了它在列表环境中的用法。下面的代码为所有的 指定了 6cm 的左缩进subq
。
\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amsthm,amssymb,lipsum}
\newenvironment{question}[2][Question]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
%%%%%%%%%%
\newenvironment{subq}[1]{\begin{trivlist}
\dimen1=\the\textwidth
\dimen2=6cm
\advance\dimen1 by -\dimen2
\parshape=1 \dimen2 \dimen1
\item[{\bfseries #1.}]}
{\end{trivlist}}
%%%%%%%
\begin{document}
\begin{question}{6}
\lipsum[2]
\end{question}
\begin{subq}{a}
\lipsum[2]
\end{subq}
\end{document}