TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is simple: how can I force-move text to the left or right (or even outside of the margins)?

Some examples would be perfect.

share|improve this question
You can use negative lengths like \hspace{-2em} or \hspace{2em}. Or \llap{<content>} or \rlap{<content>}. You can also use marginpar commands. – azetina Mar 29 '14 at 23:11
@azetina -- at the beginning of a line, you need \hspace*, otherwise it will disappear. and before an \llap at the beginning of a paragraph, \noindent is needed to get out of vertical mode; \leavevmode will be sufficient if the paragraph isn't indented. – barbara beeton Mar 30 '14 at 0:48
You could use the tabto package. (See tex.stackexchange.com/questions/33487/…) – Nathaniel Mar 30 '14 at 3:49
Please make some examples of what you'd like to obtain. – egreg Mar 30 '14 at 13:13

Does this code illustrate what you mean? I force a text to go in the margins (math and text). The \fbox are here only to show what's happening.

\documentclass[a4paper, 12pt]{article}

\usepackage[showframe, lmargin = 3cm, rmargin = 4cm, nomarginpar, , noheadfoot]{geometry}
\parindent = 0pt

Example : \medskip\\
\llap{\fbox{A text} }inserted in the left margin, \dotfill And now another text inserted\rlap{ \fbox{in the right margin.} }\\\\
 $ \mathllap{a = b\ }$This formula went strolling in the left margin \hfill and this one the right one$ \mathrlap{\ u = v. } $\\\\
You also can superimpose two pieces ot text: \quad \clap{A}\clap{V}


enter image description here

share|improve this answer
Can you remove the spurious spaces of your code? – azetina Mar 29 '14 at 23:42
What do you mean, precisely? The spaces between the boxes and the text that's inside the margins (1st line) for instance? Or maybe the blank lines in the code? – Bernard Mar 29 '14 at 23:56
inside a \...lap, an \fbox shouldn't be necessary, since the lap is itself a box. – barbara beeton Mar 30 '14 at 0:42
Your code is indented by more than 4 spaces. On a small screen, the large left margin this creates takes significant space and increases the need for horizontal scrolling for no good purpose. [At least, I'm guessing this is what the 'spurious spaces' refers to.] – cfr Mar 30 '14 at 2:22
OK, I changed that. I always thought 4 spaces were the minimum to convert the text to code, but the real number of spaces was of no importance. – Bernard Mar 30 '14 at 2:29

Since I wrote the stackengine package, I will focus solely on ways that macros of that package can exceed the margins left and right. In addition, the stacking gap allows one to move text up and down with respect to the current location.

EDIT: In my drowsiness of the original post, I forgot all about the packages \stackinset macro.

\parskip .4in
Normally stackinset is used to place things
\stackinset{c}{}{c}{}{$\bullet$}{inside} of a specified object.

However, there is nothing to prevent it from placing things
\stackinset{c}{.3in}{c}{.5in}{$\bullet$}{outside} of it.

When placed with respect to a null point, usage can be successive, 
as in the void at the end of this sentence.\smash{%

But if placement is with respect to a finite sized anchor, usage must be nested:


enter image description here


\parskip 1em\parindent 0ex
This is the margin:\par\vspace{-1.7em}

{\sffamily\Large \toplap{l}{Stackengine}ways to exceed the margin:}

centering with hsmash can fit and center a larger object:


without centering, hsmash is like a "clap", which can be used at 
either margin


while llap and rlap go left and right, toplap and bottomlap go 
above and below left and right:

{\sffamily\toplap{l}{top left lap}normal text\hrulefill 
normal text\bottomlap{r}{bottom right lap}}

useanchorwidth set "T" means the stacked material is only as 
wide as the anchor at the base:

{\sffamily\noindent\stackon{anchor}{This is my stacked text}
\hfill but if the anchor is null and the stackgap is 0pt...
\hfill \stackon[0pt]{}{stacked text}}

Use of stackalignment can magnify the effect:

\sffamily\noindent\stackon{anchor}{This is my stacked text}
\hfill but if the anchor is null and the stackgap is 0pt...
\hfill \stackon[0pt]{}{stacked text}}

This is the margin:\par\vspace{-2em}

\smash{\toplap{l}{Last Code Line}}}By setting large stackgap, voila.


enter image description here

share|improve this answer

Your Answer


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.