我想在自定义环境内的每个段落的开头添加一个标记(例如X
或)。¶
梅威瑟:
\documentclass{memoir}
\newcommand{\sometext}{
This is some text
This is some text in a new paragraph.
This is even more text in yet another new paragraph
}
\newenvironment{paragraphmarked}{%
% Magic command goes here?
}{%
% Maybe reset paragraph behaviour here?
}
\begin{document}
\begin{paragraphmarked}
\sometext
\end{paragraphmarked}
\end{document}
我目前看到的是:
我希望得到什么
我尝试过
\let\oldpar\par
\let\par{\par X}
% Text goes here
\let\par\oldpar
但这导致 TeX 在我的(相当大的)文档中耗尽内存。
答案1
有一个 TeX 命令\everypar{...}
正是用于此目的:
\documentclass{article}
\begin{document}
\everypar{X}
Text
Text
Text
\end{document}
通过用户定义的环境,\everypar{}
可以限制范围:
\documentclass{article}
\newenvironment{paragraphmarked}[1]{\everypar{#1}}{}
\begin{document}
\begin{paragraphmarked}{X}
Text
Text
Text
\end{paragraphmarked}
Text
Text
Text
\end{document}