Remove indent for fbox

indentation

The following is my Latex code in Overleaf:

\noindent\large\textbf{Title}\\
\rule{0pt}{3ex}   
\noindent\normalsize\fbox{\textbf{Theorem:} \normalsize 2 + 2 = 4}\\
\rule{0pt}{2.5ex}   
\textbf{Proof:}

It produces the following output:

enter image description here

If you notice carefully, the box is indented even though I have used \noindent. Please suggest how I can fix this. Thank you.

Best Answer

TeX puts space at the end of each non-empty line if the line doesn't end by multi-letter control sequence (spaces after such control sequence are ignored always). The spaces from end-lines are typically ignored in vertical mode. But it is not your case, TeX is in horizontal mode in your example.

At the end of first line you have \\. Space is inserted here, because it is not multi-letter control sequence. But the macro \\ expands to \hfil\break and the space is ignored as discardable item after such \break.

At the second line you have invisible item \vrule with zero width. The line ends by }, i.e. the space is inserted after the invisible item. This is a space what you want to remove. Typical solution is to add the % at the end of the line.

Third line is similar to the first: the space after \\ is removed as discardable item after \break. Fourth line is similar of the second. The space form the end line after invisible item is inserted.