我倾向于使用\paragraph{text}
来构造我的文本(而不是\subsubection
例如)。段落中的文本以粗体打印,并插入一些额外的空格。我想通过让乳胶在粗体文本后打印一个句号来改变这种情况。我可以通过定义另一个宏来实现这种效果。
\newcommand{\myparagraph}[1]{\paragraph{#1.}}
是否有某种方法可以使用更适合乳胶的方式(如变量)来实现相同的效果\paragraphDelimiter
?
答案1
从你的类中复制的定义\paragraph
(这里我使用了article
)并通过添加如下所示的内容来修改它\maybe@addperiod
:它应该是最后一个参数中的最后一个标记。
\documentclass{article}
\usepackage{amsthm} % for \@addpunct
\makeatletter
\renewcommand\paragraph{%
\@startsection{paragraph}
{4}
{\z@}
{3.25ex \@plus1ex \@minus.2ex}
{-1em}
{\normalfont\normalsize\bfseries\maybe@addperiod}%
}
\newcommand{\maybe@addperiod}[1]{%
#1\@addpunct{.}%
}
\makeatother
\begin{document}
\paragraph{This is the title} And some text follows.
\paragraph{This is the title.} And some text follows.
\paragraph{Is this is a title?} And some text follows.
\end{document}
如您所见,仅当标点符号没有结束参数时,才会打印句号\paragraph
。
如果您想要一个不需要寻找定义的版本:
\documentclass{article}
\usepackage{amsthm} % for \@addpunct
\makeatletter
\NewCommandCopy\latexparagraph\paragraph
\RenewDocumentCommand{\paragraph}{sO{#3}m}{%
\IfBooleanTF{#1}
{\latexparagraph*{\maybe@addperiod{#3}}}
{\latexparagraph[#2]{\maybe@addperiod{#3}}}%
}
\newcommand{\maybe@addperiod}[1]{%
#1\@addpunct{.}%
}
\makeatother
\begin{document}
\paragraph{This is the title} And some text follows.
\paragraph{This is the title.} And some text follows.
\paragraph{Is this is a title?} And some text follows.
\end{document}
答案2
egreg 和 Alenanno 的解决方案很棒。如果想更简单一点,下面的方法如何?
\documentclass{article}
\let\oldparagraph=\paragraph
\renewcommand\paragraph[1]{\oldparagraph{#1.}}
\begin{document}
\paragraph{Hello}
World.
\end{document}