Trying to figure out how they place the command names on the left margin on package docs on CTAN, e.g.
I have tried using marginpar
, but my text is not properly aligned. Minimal example:
\documentclass{article}
\usepackage[a4paper,left=6cm,top=2cm,right=2cm,bottom=2cm]{geometry}
\usepackage{marginnote}
\usepackage{lipsum}
\begin{document}
\reversemarginpar\marginpar{\raggedright SomeCommand}%
\lipsum[1]
\end{document}
Result:
Obviously, the text on the left is not aligned to the first line of the paragraph, which is the desired effect. I am also interested in having the text on the left to use \ttfamily
.
How should I proceed?
Best Answer
The alignment is messed up because marginpar is being invoked in vertical mode. A
\leavevmode
remedies the issue. As to\ttfamily
, it can just be added to the marginpar.If you wish to get the backslash for a command name in such a context, just use the
\char'134
primitive, as in