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.

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
2  
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 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 at 0:48
    
You could use the tabto package. (See tex.stackexchange.com/questions/33487/…) –  Nathaniel Mar 30 at 3:49
    
Please make some examples of what you'd like to obtain. –  egreg Mar 30 at 13:13

2 Answers 2

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[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[showframe, lmargin = 3cm, rmargin = 4cm, nomarginpar, , noheadfoot]{geometry}
\usepackage{mathtools}
\parindent = 0pt

\begin{document}
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}
\end{document}

Result:

enter image description here

share|improve this answer
    
Can you remove the spurious spaces of your code? –  azetina Mar 29 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 at 23:56
    
inside a \...lap, an \fbox shouldn't be necessary, since the lap is itself a box. –  barbara beeton Mar 30 at 0:42
1  
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 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 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.

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\parskip .4in
\begin{document}
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{%
\stackinset{c}{.3in}{c}{.3in}{NE}{}%
\stackinset{c}{-.3in}{c}{.3in}{NW}{}%
\stackinset{c}{-.3in}{c}{-.3in}{SW}{}%
\stackinset{c}{.3in}{c}{-.3in}{SE}{}%
}

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

\stackinset{c}{}{c}{.3in}{12}{%
\stackinset{c}{}{c}{-.3in}{6}{%
\stackinset{c}{-.3in}{c}{}{9}{%
\stackinset{c}{.3in}{c}{}{3}{%
\scalebox{19}{\rule{0ex}{1.17ex}$\circ$}%
}}}}
\end{document}

enter image description here


OTHER WAYS:

\documentclass{article}
\usepackage{stackengine}
\parskip 1em\parindent 0ex
\begin{document}
This is the margin:\par\vspace{-1.7em}
\noindent\hrulefill

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

centering with hsmash can fit and center a larger object:

{\centering\hsmash{\rule{1.1\textwidth}{1ex}}\par}

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

{\hsmash{\rule{1in}{1ex}}\hfill\hsmash{\rule{2in}{1ex}}\par}

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}}

\def\useanchorwidth{T}
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:

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

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

{\sffamily\setstackgap{L}{5.3in}
\smash{\toplap{l}{Last Code Line}}}By setting large stackgap, voila.


\end{document}

enter image description here

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.