这是我上一个问题的后续使用“environ”来列出环境列表?
最终我使用 得到了以下代码tocloft
。我试图使其成为 MWE。
\documentclass[11pt]{scrartcl}
\usepackage{amsmath, amsthm}
%% Begin question thingies
\usepackage{tocloft} % http://ctan.org/pkg/tocloft
\newtheorem{xquestion}{Question}
\newtheorem{xquestionu}[xquestion]{Question (unanswered)}
\newtheorem{xremark}[xquestion]{Remark}
\newcommand\listxquestionsname{List of Remarks and Questions}
\newlistof{questionsandremarks}{qlist}{\listxquestionsname}
% Add the answered questions
\newcommand\qdescription[1]{%
\addcontentsline{qlist}{questionsandremarks}%
{\protect\makebox[2.5em][l]{{Q.}~\hfill\thexquestion\hspace{12pt}}#1}}
% Add the unanswered questions
\newcommand\qdescriptionu[1]{%
\addcontentsline{qlist}{questionsandremarks}%
{\protect\makebox[2.5em][l]{\textit{{Q.}}~\hfill\thexquestionu\hspace{12pt}}#1}}
% Add the remarks
\newcommand\raddlist{%
\addcontentsline{qlist}{questionsandremarks}%
{\protect\makebox[2.5em][l]{{R.}~\hfill\thexremark\hspace{12pt}}}}
\newenvironment{question}[1][]{\begin{xquestion}\qdescription{#1}}{\end{xquestion}}
\newenvironment{questionu}[1][]{\begin{xquestionu}\qdescriptionu{#1}}{\end{xquestionu}}
\newenvironment{remark}{\begin{xremark}\raddlist}{\end{xremark}}
\setlength{\cftafterqlisttitleskip}{\parskip}
\renewcommand{\cftafterqlisttitle}{\\[\baselineskip] A cursive \textit{Q} means that this entry is about a question that is not (yet) answered in the text.}
%% End question thingies
\begin{document}
\begin{questionu}[A test]
Here is my question.
\end{questionu}
\begin{remark}
I also like to make remarks!
\end{remark}
\end{document}
我认为数字存在一些问题,没有正确对齐。我该如何修复?
那么,现在我的问题是:这是好的做法,还是我做错了?此外,大问题是 的编号\thex...
。它们似乎没有正确对齐。我如何将虚线更改为其他内容(也许什么都没有)?也非常欢迎告诉我良好的代码卫生!此外,如果描述超过一行,我该如何正确换行?
答案1
- 要纠正计数器的对齐,您可以移动
\hspace
外部\makebox
。 - 为了抑制点,您可以将其重新定义
\cftquestionsandremarksdotsep
为\cftnodots
。 - 我建议
\makeboxe
通过使用定义的长度来控制 s 的宽度和它们后面的水平空间的值;这样,独特的变化将确保三种条目类型的一致性。 使用
\cftsetindents
您可以控制条目的缩进。\documentclass[11pt]{scrartcl} \usepackage{amsmath, amsthm} \usepackage{tocloft} %% Begin question thingies \newtheorem{xquestion}{Question} \newtheorem{xquestionu}[xquestion]{Question (unanswered)} \newtheorem{xremark}[xquestion]{Remark} \newcommand\listxquestionsname{List of Remarks and Questions} \newlistof{questionsandremarks}{qlist}{\listxquestionsname} % Add the answered questions \newlength\Labelwidth \newlength\AfterLabelspace \setlength\Labelwidth{2em} \setlength\AfterLabelspace{10pt} \newcommand\qdescription[1]{% \addcontentsline{qlist}{questionsandremarks}% {\protect\makebox[\Labelwidth]{Q.\hfill\thexquestion}% \protect\makebox[\AfterLabelspace]{}#1}} % Add the unanswered questions \newcommand\qdescriptionu[1]{% \addcontentsline{qlist}{questionsandremarks}% {\protect\makebox[\Labelwidth]{\textit{Q}.\hfill\thexquestion}% \hspace{\AfterLabelspace}#1}} % Add the remarks \newcommand\raddlist{% \addcontentsline{qlist}{questionsandremarks}% {\protect\makebox[\Labelwidth]{R.\hfill\thexquestion}% \hspace{\AfterLabelspace}}} \newenvironment{question}[1][]{\begin{xquestion}\qdescription{#1}}{\end{xquestion}} \newenvironment{questionu}[1][]{\begin{xquestionu}\qdescriptionu{#1}}{\end{xquestionu}} \newenvironment{remark}{\begin{xremark}\raddlist}{\end{xremark}} \setlength{\cftafterqlisttitleskip}{\parskip} \renewcommand{\cftafterqlisttitle}{\\[\baselineskip] A cursive \textit{Q} means that this entry is about a question that is not (yet) answered in the text.} % suppress the dots in the new list \renewcommand\cftquestionsandremarksdotsep{\cftnodots} % set the proper indentation for the entries \cftsetindents{questionsandremarks}{0em}{\dimexpr\Labelwidth+\AfterLabelspace\relax} %% End question thingies \begin{document} \listofquestionsandremarks \begin{questionu}[A test unanswered question with a description spanning more than one line in the list of remarks and questions] Here is my question. \end{questionu} \begin{question}[A test answered question] Here is my question. \end{question} \begin{remark} I also like to make remarks! \end{remark} \end{document}