I wanted to create a newenvironment
which included a minipage
. However, I discovered that when inserting the \noindent
command inside this minipage
it creates extra space in the beginning of the line. Additionally, this spaces seems to be different when the text is long!
Also, the vertical spacing seems to behave differently within and outside a minipage.
Can someone explain why this is happening?
Here is the code that created this picture:
\documentclass[11pt]{amsart}
\newenvironment{sample_text_with_noindentation}{\begin{minipage}{0.5\textwidth}\noindent}{\end{minipage}}
\newenvironment{sample_text_without_noindentation}{\begin{minipage}{0.5\textwidth}}{\end{minipage}}
\begin{document}
\hrulefill
\begin{center}minipage in document\end{center}
\hrulefill
\begin{minipage}{0.5\textwidth}
\noindent random short text............
\end{minipage}
Horizontal spacing looks fine here,
\begin{minipage}{0.5\textwidth}
random short text............
\end{minipage}
but the first row seems further apart
\begin{minipage}{0.5\textwidth}
\noindent random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{minipage}
\begin{minipage}{0.5\textwidth}
random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{minipage}
\hrulefill
\begin{center}minipage with {$\backslash$}noindent in {$\backslash$}newenvironment in preamble\end{center}
\hrulefill
\begin{sample_text_with_noindentation}
\noindent random short text............
\end{sample_text_with_noindentation}
Seems there is an extra space
\begin{sample_text_with_noindentation}
random short text............
\end{sample_text_with_noindentation}
even with {$\backslash$}noindent
\begin{sample_text_with_noindentation}
\noindent random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{sample_text_with_noindentation}
which is bigger for long text
\begin{sample_text_with_noindentation}
random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{sample_text_with_noindentation}
again even with {$\backslash$}noindent
\hrulefill
\begin{center}minipage without {$\backslash$}noindent in {$\backslash$}newenvironment in preamble\end{center}
\hrulefill
\begin{sample_text_without_noindentation}
\noindent random short text............
\end{sample_text_without_noindentation}
However, if you remove {$\backslash$}noindent
\begin{sample_text_without_noindentation}
random short text............
\end{sample_text_without_noindentation}
from the custom environment,
\begin{sample_text_without_noindentation}
\noindent random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{sample_text_without_noindentation}
everything looks fine
\begin{sample_text_without_noindentation}
random text which very long long long very long very long and it goes beyond the margins so it reaches the other line............
\end{sample_text_without_noindentation}
(except the vertical spacing)
\hrulefill
\end{document}