4

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.

Sean Allred
  • 27,421
  • You're wrong in believing that \llap would print its argument in the left margin. – egreg Jun 21 '14 at 18:21
  • I'm not sure what you are asking for but it sounds like \marginpar? – David Carlisle Jun 21 '14 at 18:22
  • @egreg I know that; \llap and friends are pretty particular commands. I believe they're mostly equivalent to \makebox[r]{#1} (with [r], [l], and [c] as appropriate) – Sean Allred Jun 21 '14 at 18:23
  • @DavidCarlisle Much more like \marginpar, yes, but… I dunno. \marginpar I know is a 'floating' thing (sort of) and I think that is the kind of behavior I'm asking for. TeX doesn't know where to put it until it has computed the linebreaks. Is http://tex.stackexchange.com/q/101553 the answer I'm looking for? It just seems… needlessly complicated. – Sean Allred Jun 21 '14 at 18:25
  • you've tagged this "plain-tex", but all comments and answer so far have referred to latex commands. do you really mean non-latex? eplain implements index terms in the (right-hand) margin; you might be able to get some ideas there. – barbara beeton Jun 21 '14 at 19:11
  • @barbarabeeton I do in fact mean a plain TeX command, but non-LaTeX makes sense, too. As far as I know, most plain commands are available in LaTeX. I'll take a look at eplain—thanks :) – Sean Allred Jun 22 '14 at 03:06

1 Answers1

4

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}
David Carlisle
  • 757,742