问题描述
\documentclass[11pt]{article}
\renewcommand{\contentsname}{Inhalt}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2cm,bottom=2cm]{geometry}
\usepackage{blindtext}
\newcommand{\indexentry}[1]{
\normalsize
{\vspace{5mm}\Large\textbf{#1}\vspace{5mm}}\\*
\addcontentsline{toc}{section}{#1}
}
\setlength{\parindent}{0pt}
\begin{document}
\tableofcontents
\section{blub}
\blindtext
\subsection{foo}
\blindtext
\subsection{bar}
\blindtext
\subsection{baz}
\blindtext
\indexentry{test}
\blindtext
\end{document}
不知何故,我在自定义 \indexentry{} 部分之后的段落中缩进了这样的:
我如何防止这种情况发生?
我已经添加了 \setlength{\parindent}{0pt} 以防止其他段落出现这种情况,但它似乎不会影响我的自定义部分段落。
解决方法
我认为您正在寻找 indexentry
函数的不同方法:
\newcommand{\indexentry}[1]{
\normalsize
\section*{#1}
\addcontentsline{toc}{section}{#1}
}
,
您在某些行的末尾缺少 %
。这些未受保护的行结尾会被解释为空格,您看到的不是缩进(这就是 \setlength{\parindent}{0pt}
不起作用的原因),而是几个空格的累积。
\documentclass[11pt]{article}
\renewcommand{\contentsname}{Inhalt}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=2cm,bottom=2cm]{geometry}
\usepackage{blindtext}
\newcommand{\indexentry}[1]{%
\normalsize%
{\vspace{5mm}\Large\textbf{#1}\vspace{5mm}}\\*%
\addcontentsline{toc}{section}{#1}%
}
\setlength{\parindent}{0pt}
\begin{document}
\tableofcontents
\section{blub}
\blindtext
\subsection{foo}
\blindtext
\subsection{bar}
\blindtext
\subsection{baz}
\blindtext
\indexentry{test}%
\blindtext
\end{document}