[Tex/LaTex] Placing symbol in margin


I am using


which I use in sections as \section{\margin_symbol My Header} to place an X 3cm to the left in the margin; however, my problem is that I'm both using it in sections and subsections and therefore the symbols are placed at different horizontally positions.

Can I somehow place the at an absolute position in the margin rather than 3cm to the left as it does now?

Best Answer

This implementation with the tabto package will work with certain limitations. Primarily, when \marginsymbol appears in any sectioning macro argument, it must be the last item in the argument. Second, if you are using a table of contents, or a chapter page-heading, you will need to use the optional argument of the sectioning macro to exclude the margin mark.

\section[My Header]{My Header\marginsymbol}

\subsection{My subsection Header\marginsymbol}

this is an inline \marginsymbol test. \lipsum[1]

\subsection{My subsubsection Header\marginsymbol}

enter image description here


The OP asks if it can be done for the table of contents, as well. Here is a way, but it does not address the issue of chapter-page headings that I cited above. So, for the article class, where that is not a direct issue, I provide a revised version of \marginsymbol[<length>] with an optional length argument that is only applied in the toc as an added leftward offset, in order to handle the staggered entries of toc subcategories.



\section{My Header\marginsymbol}

\subsection{My subsection Header\marginsymbol[23pt]}

\subsubsection{My subsubsection Header\marginsymbol[55pt]}

\section{My New Header\marginsymbol}


enter image description here

Related Question