セクションとサブセクションを異なる方法でインデントする方法

セクションとサブセクションを異なる方法でインデントする方法

すべてのセクションで 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

段落は常にインデントするか(タイトル後の最初の段落は例外)、またはインデントしない(各段落の前に垂直方向のスペースを追加)必要があります。2 番目のスタイルは、手紙などの短い文書に使用できます。

インデントされた段落とインデントされていない段落を混在させると、読者を混乱させるので、お勧めできません。また、2 mm のインデントは小さすぎます。

やりたいことは簡単にできます。でも、やめてください。

\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}

ここに画像の説明を入力してください

関連情報