[Tex/LaTex] Place text on left margin

marginsplain-texpositioning

Maybe I'm just not searching for the right thing, because this seems to be something that TeX would just 'have something' for.

Is there any way to simply return to the left margin (or originating margin, in the case of bidi documents)? I want functionality similar to how \llap behaves when you use it on the start of a line. (This might be a bit of a red herring though, since interfacing with TeX's computed linebreaks is, in my experience, very messy.)

MWE

\documentclass{article}

\newcommand\mystery[1]{%
    Should be placed on left margin: \llap{#1}}

\begin{document}
Hello. This is some text to push this out to the side: \mystery{test}
\end{document}

I'd like to be able to put any hbox into \mystery, if possible.

Best Answer

sounds like marginpar, but if you want something that never floats (and will over-print if you put two on a line, then the second form)

\documentclass{article}
\reversemarginpar
\newcommand\mystery[1]{\marginpar{\raggedleft #1}}

\newcommand\mysteryb[1]{%
\strut\vadjust{\kern-\dp\strutbox\llap{\smash{\parbox[t]{\marginparwidth}{\raggedleft#1}}\kern\marginparsep}}}

\begin{document}
\noindent Hello. This is some text to push this out to the side: \mystery{test}


\noindent Hello. This is some text to push this out to the side: \mysteryb{test}

\end{document}