两条基线之间的箭头

两条基线之间的箭头

考虑以下 MWE:

\documentclass[a4paper,12pt]{article}

\def\texttext{This is a sample text}
\newlength{\textlength}
\settowidth{\textlength}{\texttext}

\begin{document}
\thispagestyle{empty}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}

\end{document}

我想在基线之间画一个双向箭头。毫无疑问,使用 TikZ 可以实现这一点,但是也可以在普通的 Latex 中实现吗?

答案1

这是一个解决方案(经过反复试验):

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath, amssymb, old-arrows}
\usepackage{graphicx}

\def\texttext{This is a sample text}
\newlength{\textlength}
\settowidth{\textlength}{\texttext}

\makeatletter
\newcommand\xleftrightarrow[2][]{%
 \ext@arrow 9999{\longleftrightarrowfill@}{#1}{#2}}
\newcommand\longleftrightarrowfill@{%
 \arrowfill@\leftarrow\relbar\rightarrow}
\makeatother


\begin{document}
\thispagestyle{empty}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}\raisebox{-0.62ex}[0pt][0pt]{ \rotatebox[origin=l]{-90}{$ \xleftrightarrow{\makebox[1.44ex]{}} $}}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}

\end{document} 

enter image description here

答案2

我认为这\resizebox是作弊?

\documentclass[a4paper,12pt]{article}

\def\texttext{This is a sample text}
\newlength{\textlength}
\settowidth{\textlength}{\texttext}

\newcommand{\clap}[1]{\bgroup
  \sbox0{#1}%
  \hspace{-0.5\wd0}\usebox0\hspace{-0.5\wd0}%
\egroup}

\begin{document}
\thispagestyle{empty}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}

\rule{5pt}{.1pt}\rule{\textlength}{.1pt}\kern-\textlength \texttext\rule{5pt}{.1pt}%
  \clap{\raisebox{\depth}[0pt]{\large$\updownarrow$}}

\end{document}

demo

相关内容