更改段落開始/結束指令

更改段落開始/結束指令

是否可以修改 TeX/LaTeX 指令,以便在段落之前/之後執行某些指令?例如,我們知道,當 LaTeX 編譯器看到 \par 命令或空白行時,它會結束當前段落並進入垂直模式(?)。

所以,我正在尋找一個可以修改的命令,以便我可以輸入

%redefine some commands up here

\begin{document}
Paragraph 1

Paragraph 2
\end{document}

並讓它產生相同的輸出

\begin{document}
$\triangle$Paragraph 1

$\triangle$Paragraph 2
\end{document}

另一個相關的問題也會產生類似的輸出

\begin{document}
Paragraph 1$\square$

Paragraph 2$\square$
\end{document}

答案1

全域重新定義\par是非常危險的。但受限於環境,可以在不編寫任何命令的情況下添加一些元素。例子:

(不保證真實文件的安全性)

微量元素

\documentclass{article}
\usepackage{xcolor}

\newenvironment{crazypar}{%at begin 
\smallskip
\def\par{%
\pdfprimitive\par\noindent\rule{\textwidth}{0.4mm}%
\pdfprimitive\par\makebox[-2em][c]{\color{red}$\triangle$}\hspace{1.5em}
}}%
{%at end
\newline\noindent\rule{\textwidth}{0.4mm}
}


\begin{document}

This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text.

This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. 

This is a dummy text. This is a dummy text.

\begin{crazypar}

This is a dummy text. 

This is a dummy text. This is a dummy text. This is a dummy text.

This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text.

This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text.  % no blank line here
\end{crazypar}

This is a dummy text. This is a dummy text. This is a dummy text. This is a dummy text.

\end{document}

相關內容