如何删除定理名称前面插入的空格?即括号左侧的空格。我希望括号左对齐。
由于某种原因,我无法理解该\newtheoremstyle
命令。
\documentclass{beamer}
\usepackage[english]{babel}
\theoremstyle{definition}
\newtheorem{mydef}{}[theorem]
\begin{document}
\begin{frame}
\noindent Here is a sentence with correct alignment
\begin{mydef}[This name is prefixed by a single space]
This is a definition
\end{mydef}
\noindent Here
\end{frame}
\end{document}
答案1
通常在定理名称和附加文本之间有一个硬编码空格。要删除此空格,您可以重新定义模板theorem begin
:
\documentclass{beamer}
\usepackage[english]{babel}
\theoremstyle{definition}
\newtheorem{mydef}{}[theorem]
\makeatletter
\setbeamertemplate{theorem begin}
{
\normalfont
\begin{\inserttheoremblockenv}
{%
\inserttheoremname%
\ifx\inserttheoremaddition\@empty\else%\ <- Removed this space
(\inserttheoremaddition)\fi%
}%
}
\makeatother
\begin{document}
\begin{frame}
\noindent Here is a sentence with correct alignment
\begin{mydef}[This name is prefixed by a single space]
This is a definition
\end{mydef}
\noindent Here
\end{frame}
\end{document}
答案2
一个解决方案..但在接受之前请等待更好的答案:
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\def\tikzmark#1{\begin{tikzpicture}[remember picture]\coordinate (#1);\end{tikzpicture}}
\theoremstyle{definition}
\newtheorem{mydef}{\hskip-0.375em}[theorem]% Here is the only change needed
\begin{document}
\begin{frame}
\tikzmark{A}Here is a sentence with correct alignment
test
\begin{mydef}[This name is prefixed by a single space]
This is a definition
\end{mydef}
\tikzmark{B}Here
\begin{tikzpicture}[overlay,remember picture]
\draw[red,-] ([yshift=1em]A)--(B);
\end{tikzpicture}
\end{frame}
\end{document}