# Horizontal spacing in environments

I don't seem to understand how spacing in environments works: Look at

\documentclass{article}

\usepackage{amsthm}

\newenvironment{myproof}{\par\noindent\textit{Proof.}}{\qed}
\newenvironment{myproof2}[1][Proof]{\par\noindent\textit{#1.} }{\qed}
\newenvironment{myproof3}[1][Proof]{\par\noindent\textit{#1.}}{\qed}

\begin{document}
\begin{proof}
I
\end{proof}

\begin{myproof}
I
\end{myproof}

\begin{myproof2}
I
\end{myproof2}

\begin{myproof3}
I
\end{myproof3}
\end{document}


Why don't I have to include a space manually if I don't use an option, but have to use one if I include the capability of optional arguments?

Why are my spaces smaller than those of amsthm? I would like to have them as in the original proof environment.

• Why not using the original? – egreg Apr 13 '18 at 8:11
• @egreg I want to create a proof-of-claim-inside-a-proof environment with an alternative qed symbol, less vertical spacing, etc. – John Dorian Apr 13 '18 at 8:13

Tell LaTeX to ignore subsequent spaces:

\documentclass{article}

\usepackage{amsthm}

\usepackage[nopar]{lipsum}

\newcommand{\closedbox}{%
\makebox[0.77778em]{\rule{0.675em}{0.675em}}%
}

\newenvironment{innerproof}[1][Proof]
\renewcommand{\qedsymbol}{\closedbox}%
\noindent\textit{#1.}\hspace{\labelsep}\ignorespaces}

\begin{document}

\openbox\closedbox

\begin{proof}
\lipsum[4]
\begin{innerproof}
\lipsum[5]
\end{innerproof}
\lipsum[6]
\begin{innerproof}[Proof of claim]
\lipsum[5]
\end{innerproof}
\lipsum[6]
\end{proof}

\end{document}


• Thank you very much. So the correct length of the space was \labelsep. Btw I was not aware that \renewcommand does not have a global effect if put inside {}. Learned something again :-) – John Dorian Apr 13 '18 at 8:38
• This is of course not relevant to your proof of concept, but I think your black square is bigger than the original \qedsymbol. – John Dorian Apr 13 '18 at 8:39
• @JohnDorian Fixed the size. – egreg Apr 13 '18 at 10:58