考虑
\documentclass{article}
\usepackage{amsthm}
\newtheoremstyle{boldtheorem}
{}
{}
{\itshape}
{}
{}
{\itshape}
{}
{\bfseries}
{.}
{ }
{\thmnumber{#2}\ifx #3\relax\relax\thmname{ #1}\else\thmnote{ #3}\fi}
\theoremstyle{boldtheorem}
\newtheorem{theorem}{Theorem}[section]
\begin{document}
\end{document}
用 进行编译会在行上latex
出现缺失错误。\begin{document}
{.}
删除.
会出现错误
! You can't use `macro parameter character #' in vertical mode.
<argument> ##
2
l.14 {\thmnumber{#2}
\ifx #3\relax\relax\thmname{ #1}\else\thmnote{ #3}\fi}
这是从较大的前言中提取的。我已使用 vim 命令删除了所有不可打印字符:%s/[^[:print]]//g
,但错误仍然存在。删除.aux
文件似乎没有效果。
有任何想法吗?
答案1
来自thmtest.tex
(已编辑)
\newtheoremstyle{<name>}% name
{<dimen>}% Space above
{<dimen>}% Space below
{<font>}% Body font
{}% Indent amount (empty = no indent, \parindent = para indent)
{<font>}% Thm head font
{<punct>}% Punctuation after thm head
{<dimen>}% Space after thm head: " " = normal interword space; \newline = linebreak
{<spec>}% Thm head spec (can be left empty, meaning `normal')
如果算一下参数的数量,正好有九个。
所以你可能想要
\newtheoremstyle{boldtheorem}
{\topsep}
{\topsep}
{\itshape}
{}
{\bfseries}
{.}
{ }
{\thmnumber{#2}\ifx\relax#3\relax\thmname{ #1}\else\thmnote{ #3}\fi}
请注意#3
必须之间\relax
如果你想测试它是否为空,则可以使用这两个标记。
\documentclass{article}
\usepackage{amsthm}
\usepackage{lipsum} % just for the example
\newtheoremstyle{boldtheorem}
{\topsep}
{\topsep}
{\itshape}
{}
{\bfseries}
{.}
{ }
{\thmnumber{#2}\ifx\relax#3\relax\thmname{ #1}\else\thmnote{ #3}\fi}
\theoremstyle{boldtheorem}
\newtheorem{theorem}{Theorem}[section]
\begin{document}
\section{Title}
\lipsum[2]
\begin{theorem}
This is a theorem.
\end{theorem}
\lipsum[3]
\begin{theorem}[Fancy theorem]
This is a fancy theorem.
\end{theorem}
\lipsum[4]
\end{document}