# Spurious horizontal space after \mbox{}\vskip0pt\noindent

How can one avoid the horizontal space (text indentation) created by the new line in the environment defined below?

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{amsthm}

\makeatletter
\newenvironment{environment}[1]{\par
\normalfont\topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries Environment #1]\mbox{}\vskip0pt\noindent
}{%
\endtrivlist\@endpefalse
}
\makeatother

\begin{document}
\begin{environment}{(Title)}
Just some text\dots{}
\end{environment}
\end{document}

• since you are loading amsthm anyway why not simply use the \newline option to specify a break after a theorem title rather than doing it this way? Oct 1 '15 at 11:41

It's not indentation it is a space, as you can see if you put a % after {(title)} you can ignore spaces in the source file by:

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{amsthm}

\makeatletter
\newenvironment{environment}[1]{\par
\normalfont\topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep
\sffamily\bfseries Environment #1]\mbox{}\vskip0pt\noindent\ignorespaces
}{%
\endtrivlist\@endpefalse
}
\makeatother

\begin{document}
\begin{environment}{(Title)}
Just some text\dots{}
\end{environment}
\end{document}

• \vskip0pt is a rather odd way of adding a paragraph break! Oct 1 '15 at 11:37
• Hi David, thanks a lot. I just figured out that when I put the solution into my original problem, I still see the space... so I guess my MWE is too minimal. Let me figure out more and post an update later. Oct 1 '15 at 12:03
• Ahh... I see the horizontal space if I add \label{foo} after ...(Title)}. Adding % then will avoid it again. But why does the label generate a space here? I've never seen this (in other environments). Oct 1 '15 at 12:08
• @MariusHofert the label doesn't generate a space: you have added a space after the label. The reason it happens here is that this is the wrong way to have a heading, latex never starts a paragraph and uses \noindent you should stay in vertical mode but arrange that any following paragraph is not indented. This is what the standard heading and theorem environments do. If you were in vertical mode the spaces would not be a problem. Oct 1 '15 at 12:48
• Hi David. You sound as if this wasn't the right approach... I actually first tried to define my own theorem style for that, but failed... I posted the original (actual) problem as a new MWE on tex.stackexchange.com/questions/270567/… so that you (and others) can see what I want to do. Maybe there's a better solution. Thanks again (and I'll accept your answer now). Oct 1 '15 at 15:02