0

How do I remove the space inserted prior to the theorem name? That is, the space to the left of the bracket. I want the bracket to align to the left.

For some reason I'm not able to understand the \newtheoremstyle command.

\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}

enter image description here

1
  • The answers hint at it, but this is caused because the expected form is \newtheorem{mydef}{Def.}[theorem] which leads to Def. (This name...). Leaving out Def. leaves the space.
    – Teepeemm
    Commented Feb 27, 2018 at 2:03

2 Answers 2

2

Normally there a hard coded space between the theorem name and the additional text. To remove this space, you could redefine the theorem begin template:

\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}

enter image description here

2

A fix.. But wait for better answers before accept:

\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}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .