3

How can I restore indentation in this setup?

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{marginnote,lipsum}
\reversemarginpar
\setlength{\marginparwidth}{1.1in}

\ProvideDocumentCommand{\LetterSection}{m}{%
  \par
  \smallskip
  \leavevmode
  \marginnote{%
    \raggedleft
    \footnotesize
 %   \sffamily
 %   \scshape
    \strut #1
  }[1pt]%
%  \ignorespaces
}

\begin{document}

\LetterSection{test}
\noindent\lipsum[1][1]

\end{document}

enter image description here

2
  • 3
    In \leavevmode\noindent text, \noindent has no effect. Commented Apr 13 at 4:33
  • 1
    As pointed by Stephen the issue comes from \leavevmode and is not related with marginnote. Why did you add this \leavevmode? Commented Apr 13 at 7:24

2 Answers 2

3

In my opinion you're misusing \marginnote.

\documentclass{article}
\usepackage[
  letterpaper,% since you're using inches
  showframe,
]{geometry}
\usepackage{lipsum}

\NewDocumentCommand{\LetterSection}{m}{%
  \par
  \smallskip
  \noindent
  \makebox[0pt][r]{%
    \smash{\parbox[t]{1.1in}{\setuplettersection #1}}%
    \hspace{\marginparsep}%
  }%
  \ignorespaces
}
\newcommand{\setuplettersection}{%
  \raggedleft
  \footnotesize
%  \sffamily
%  \scshape
}

\begin{document}

\LetterSection{test}
\lipsum[1][1-3]

\LetterSection{Longer text for the margin note}
\lipsum[1][1][1-3]

\end{document}

I see no reason at all for \ProvideDocumentCommand.

output

2
  • "In my opinion you're misusing \marginnote." Why is that, please? Commented Apr 13 at 11:23
  • Because, as you see, it's unnecessary. Commented Apr 13 at 11:59
3

You can use \OmitIndent in the para/begin hook to suppress indentation.

I added a * form to suppress the suppression of indentation, in case you need that, too.

\documentclass{article}
\usepackage[showframe,marginparwidth=1.1in]{geometry}
\usepackage{marginnote,lipsum}
\reversemarginpar

\ProvideDocumentCommand{\LetterSection}{sm}{%
  \smallskip
  \par
  \marginnote{%
    \raggedleft
    \footnotesize
    \strut #2
    \AddToHookNext {para/begin}{%
      \IfBooleanF{#1}{\OmitIndent}%
    }%
  }[1pt]%
}

\begin{document}

\LetterSection{test}
\lipsum[1][1]

\LetterSection*{test}
\lipsum[1][1]

\end{document}

with and without the star

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.