
Como posso escrever dois caracteres no mesmo lugar?
Em particular, quero escrever uma seta $\rightarrow$
e, em seguida, escrever uma carta de forma que a seta atravesse a letra. Encontrei algumas perguntas semelhantes (Símbolo de intervalo sobre caractere,Substitua um caractere por outro (Lualatex), etc.), mas não são exatamente a mesma pergunta.
Responder1
Não está claro se você deseja em texto ou matemática ...
\documentclass{article}
\usepackage{stackengine}
\begin{document}
In te\stackengine{0pt}{x}{$\rightarrow$}{O}{c}{F}{T}{L}t...
$\ensurestackMath{\stackengine{0pt}{y}{\rightarrow}{O}{c}{F}{T}{L}} = mx + b$
\end{document}
Além disso, não está claro se você deseja que a largura da seta seja considerada:
\documentclass{article}
\usepackage{stackengine}
\begin{document}
In te\stackengine{0pt}{x}{$\rightarrow$}{O}{c}{F}{F}{L}t...
$\ensurestackMath{\stackengine{0pt}{y}{\rightarrow\!}{O}{c}{F}{F}{L}} = mx + b$
\end{document}
Outras coisas que podem ser facilmente ajustadas acima incluem o alinhamento horizontal (atualmente centralizado), bem como a altura vertical do posicionamento da seta (atualmente colocada em sua altura natural).
Depois que as especificidades do caso de uso forem decididas, isso pode ser facilmente encapsulado em uma macro.
Abaixo, acompanhando as egregs, implemento uma versão macro ( \overarrow
) para matemática que preserva o estilo matemático:
\documentclass{article}
\usepackage{stackengine,scalerel}
\newcommand\overarrow[1]{\ThisStyle{\ensurestackMath{%
\stackengine{0pt}{\SavedStyle#1}{\SavedStyle\rightarrow\!}{O}{c}{F}{F}{L}}}}
\begin{document}
$\overarrow{y} = mx_{\overarrow{z}} + b$
\end{document}
Responder2
Responder3
Aqui está o texto em duas versões:
\documentclass{article}
\DeclareRobustCommand{\asA}[1]{% arrow strike
\leavevmode\begingroup
\vphantom{#1}%
\ooalign{\hidewidth$\mathsurround0pt\rightarrow$\hidewidth\cr#1\cr}%
\endgroup
}
\DeclareRobustCommand{\asB}[1]{% arrow strike
\leavevmode\begingroup
\vphantom{#1}%
\ooalign{$\mathsurround0pt\rightarrow$\cr\hidewidth#1\hidewidth\cr}%
\endgroup
}
\begin{document}
st\asA{r}uck
st\asB{r}uck
\end{document}
Para matemática:
\documentclass{article}
\makeatletter
\DeclareRobustCommand{\as}[1]{% arrow strike
{\vphantom{#1}\mathpalette\erel@as{#1}}%
}
\newcommand{\erel@as}[2]{%
\ooalign{\hfil$\m@th#1\rightarrow$\hfil\cr\hfil$\m@th#1#2$\hfil\cr}%
}
\makeatother
\begin{document}
$a+\as{b}+c_{\as{x}}$
\end{document}
Responder4
Caso você queira um pouco de flexibilidade e a seta para se ajustar à largura do material que está passando, você pode usar tikzmark
.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcounter{atm}
\newcommand{\arrowthrough}[2][]{\stepcounter{atm}\tikzmarknode[path picture={
\draw[->,#1] (path picture bounding box.west) --
(path picture bounding box.east);}]{atm-\theatm}{#2}}
\begin{document}
\arrowthrough{x}
\[ E=\arrowthrough{m}c^2\]
\arrowthrough[red,-latex]{Hello} \arrowthrough[latex-,thick,blue]{World!}
\end{document}