我如何强制移动文本?

我如何强制移动文本?

我的问题很简单:如何强制将文本移动到左侧或右侧(甚至移动到边距之外)?

有些例子就很完美了。

答案1

这段代码能说明您的意思吗?我强制将文本放在边距中(数学和文本)。\fbox 仅用于显示正在发生的事情。

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

结果:

在此处输入图片描述

答案2

由于我编写了这个stackengine包,因此我将只关注该包的宏如何超出左右边距。此外,堆叠间隙允许人们根据当前位置上下移动文本。

编辑:在原始帖子的昏昏欲睡中,我忘记了有关包宏的所有信息\stackinset

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

在此处输入图片描述


其他方法:

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

在此处输入图片描述

相关内容