Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
You're wrong in believing that \llap would print its argument in the left margin. –  egreg Jun 21 at 18:21
    
I'm not sure what you are asking for but it sounds like \marginpar? –  David Carlisle Jun 21 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 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 tex.stackexchange.com/q/101553 the answer I'm looking for? It just seems… needlessly complicated. –  Sean Allred Jun 21 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 at 19:11

1 Answer 1

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.