如何避免 \input 之後由前面的換行符號引起的自動縮排

如何避免 \input 之後由前面的換行符號引起的自動縮排

微量元素:

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\begin{document}

\section{Some Section}

First (long) paragraph. \\
Second (long) paragraph. \\ 
\input{some_figure}
Third (long) paragraph. \\
Fourth (long) paragraph.

\end{document}

其中some_figure.txt包含

\begin{figure}[t]
\includegraphics[width=3cm]{example-image} 
\end{figure}

\\「第二(長)段落」之後的換行符。導致後續行“第三(長)段落”中自動縮排。如下圖所示。

在此輸入影像描述

有沒有辦法(自動)避免/停用這些縮排?

我通常\input{some_figure}在一個部分的開頭/結尾移動來避免這個問題。但是,如果文字變得很大,這實際上並不是一個選擇。

答案1

如果你指的是實際的“段落”,那麼請採納egreg的建議(“不要用\\結束段落,而是用空白行”)。但是,如果您只是強制換行,那麼問題不在於縮排,而是雜散空格。

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx,filecontents}
\begin{filecontents*}{some_figure}
\begin{figure}[t]
\includegraphics[width=3cm]{example-image} 
\end{figure}
\end{filecontents*}

\begin{document}

\section{Some Section}

First (long) paragraph. \\
Second (long) paragraph. \\ 
\input some_figure \unskip
Third (long) paragraph. \\
Fourth (long) paragraph.

\end{document}

在此輸入影像描述

交替,

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx,filecontents}
\begin{filecontents*}{some_figure}
\begin{figure}[t]
\includegraphics[width=3cm]{example-image} 
\end{figure}
\end{filecontents*}

\begin{document}

\section{Some Section}

First (long) paragraph. \\
Second (long) paragraph.
\input some_figure \\
Third (long) paragraph. \\
Fourth (long) paragraph.

\end{document}

相關內容