![代码](https://linux22.com/image/296305/%E4%BB%A3%E7%A0%81.png)
我想在新章节后缩进第一段,但我不想缩进新行....我知道 indentfirst 和 parskip 包,但它们不能一起使用!我想结合两者的功能,但 parskip 会覆盖 indentfirst....
先感谢您!
这是一个代码示例:
\documentclass[a4paper, oneside]{report}
\usepackage{indentfirst}
\begin{document}
%This is going to indent (ok):
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
%This is going to indent (bad):
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
\end{document}
\documentclass[a4paper, oneside]{report}
\usepackage{parskip}
\begin{document}
%This is not going to indent (bad):
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
%This is not going to indent (ok):
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
\end{document}
答案1
背景
在通常的印刷实践中,通常会区分经典段落:通常使用缩进来区分彼此.还有现代段落:取消缩进,而是在段落之间用空行来区分。
当然,还有其他类型的段落,但并不那么流行,了解上述两种段落之间的区别就足够了。没有哪种段落比另一种更好,但事实是,无论你决定使用哪种段落,你都需要保持一致,不要混淆它们。
正文通常LaTeX
以经典的段落形式撰写,除非序言另有说明。
现在说到缩进,缩进是一种视觉标记,用于显示一个段落的结束和另一个段落的开始。但是,如果后面的空白足以让读者明白这是一个新段落,而不是前一个段落的延续,那么缩进在开头段落中是多余的,有时在一些浮动对象之后也是多余的。就像您要求的那样。
原因
规则很简单:无论标题是什么,都不要紧跟在段落后面缩进段落。
因为它是多余的,不必要的。标题本身就告诉你然后开始一个新段落,因此出血是多余的。
有时我会删除其他位置的缩进,例如在用于撰写法律页面的小页面中。
关于使用包自动执行此任务,了解这一点很有趣,我很久以前做过非常浅显的测试,但并不满意。
简而言之
您所要求的内容在 中是可以实现的LaTeX
,但不建议这样做。出版业已有 500 多年的传统,其所体现的某些准则并非出于一时兴起或少数人强加,而是经过时间考验的合理性和实用性。
换句话说,不要缩进标题后的第一行,没有必要这样做,也没有理由为了可读性而这样做,这应该是可以这样做的原因。讽刺的是,这才是最受影响的。
问候。
答案2
虽然我认为 Aradnix 在概念层面上所说的话完全正确(你不应该使用你所要求的东西),但我会给你另一种实现它的可能性。
我扩展了 skpblack 的答案,并将其附加\ind
到\section
,这样就不必手动调用它了。我使用了 Werner 的答案如何将代码附加到某个部分?去做这个。
代码
\documentclass[a4paper, oneside]{report}
\newlength{\oldparindent}
\setlength{\oldparindent}{\parindent} % Save \parindent before of change
\setlength{\parskip}{0.5\baselineskip \advance\parskip by 0pt plus 2pt} % Definition of `parskip`
\setlength{\parindent}{0pt}
\newcommand{\ind}{\hspace*{\oldparindent}} % Command to indent manually
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@xsect} % <cmd>
{\ignorespaces} % <search>
{\ind} % <replace>
{}{} % <success><failure>
\makeatother
\begin{document}
\section{First}
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
\section{First}
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
\end{document}
文档
建议
正如我所说:遵循 Aradnix 的描述并避免这种奇怪的缩进方式。当我开始使用 LaTeX 时,我必须学习的一条规则是,只有当我有合理且正当的理由时才更改其默认值。我看不出有任何理由去做你想做的事。或者你看得出来?
答案3
由于您只想缩进该部分的开头,我认为手动执行此操作更容易(因为它根本不是段落),因此我为其创建了一个新命令\ind
(类似于\indent
但它可以与 一起使用\oldparindent
)并复制帕斯基普在更改它之前保存\parindent
(在)。\oldparindent
这是我的代码
\documentclass[a4paper, oneside]{report}
\newlength{\oldparindent}
\setlength{\oldparindent}{\parindent} % Save \parindent before of change
\setlength{\parskip}{0.5\baselineskip \advance\parskip by 0pt plus 2pt} % Definition of `parskip`
\setlength{\parindent}{0pt}
\newcommand{\ind}{\hspace*{\oldparindent}} %Command to indent manually
\begin{document}
\section{First}
\ind This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
This life, which had been the tomb of his virtue and of his honour, is but a walking shadow; a poor player, that struts and frets his hour upon the stage, and then is heard no more: it is a tale told by an idiot, full of sound and fury, signifying nothing.
\end{document}
因此您应该做的是\ind
在每个 后面添加\section{}
。