![如何以不同方式缩进章节和小节](https://linux22.com/image/477033/%E5%A6%82%E4%BD%95%E4%BB%A5%E4%B8%8D%E5%90%8C%E6%96%B9%E5%BC%8F%E7%BC%A9%E8%BF%9B%E7%AB%A0%E8%8A%82%E5%92%8C%E5%B0%8F%E8%8A%82.png)
我想在所有部分中将 parindent 设置为 2mm,在所有子部分中将 parindent 设置为 0mm。有办法吗?
谢谢 Ráď
\documentclass{article}
\begin{document}
\section{Section1}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.Etiam placerat porta massa eu malesuada.
This text has a space before it. Integer egestas venenatis ipsum, et interdum nulla sagittis sed.
\subsection{Subsection1}
Fusce egestas ultricies turpis eget fermentum.
I want this text alligned. Maecenas sed scelerisque arcu.
\end{document}
答案1
段落应该总是缩进(标题后的第一个段落可能例外)或者从不缩进(并且应该在每个段落前面添加一些垂直空间);第二种样式可用于信件等短篇文件。
混合缩进和非缩进段落会使读者感到困惑;我不建议这样做。此外,2mm 的缩进量太小了。
你可以轻易地做你想做的事。请不要这么做。
\documentclass{article}
\usepackage{indentfirst}
\let\LaTeXsection\section
\let\LaTeXsubsection\subsection
\def\section{\setlength{\parindent}{2mm}\LaTeXsection}
\def\subsection{\setlength{\parindent}{0mm}\LaTeXsubsection}
\begin{document}
\section{Section1}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.Etiam placerat porta massa eu malesuada.
This text has a space before it. Integer egestas venenatis ipsum, et interdum nulla sagittis sed.
\subsection{Subsection1}
Fusce egestas ultricies turpis eget fermentum.
I want this text alligned. Maecenas sed scelerisque arcu.
\section{Section1}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.Etiam placerat porta massa eu malesuada.
This text has a space before it. Integer egestas venenatis ipsum, et interdum nulla sagittis sed.
\subsection{Subsection1}
Fusce egestas ultricies turpis eget fermentum.
I want this text alligned. Maecenas sed scelerisque arcu.
\end{document}