# Newtheorem adds a space before theorem name

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}


• 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 Feb 27 '18 at 2:03

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

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


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}