可變長度的垂直箭頭

可變長度的垂直箭頭

我希望有一個從頁面頂部到文字的垂直箭頭,箭頭的長度自動調整(如垂直填充)。

請指教。

答案1

您可以使用TikZ:

\documentclass{article}
\usepackage[a6paper]{geometry}
\usepackage{tikz}
\usepackage{lipsum}

\newcounter{myarr}
\newcommand\VArrow[1][]{%
  \stepcounter{myarr}%
  \begin{tikzpicture}[remember picture, overlay]
  \coordinate (\themyarr);
  \draw[red,thick,->,#1] (\themyarr|-current page.north) -- (\themyarr);
  \end{tikzpicture}
}
\begin{document}

Some test text\VArrow and some more text goes here
\lipsum[2]
And now some more text to draw another arrow.\VArrow[blue,ultra thick,-latex]

\end{document}

在此輸入影像描述

的可選參數允許\VArrow將選項傳遞給\draw內部用於繪製箭頭的命令。

由於一些計算是內部執行的。程式碼需要運行兩到三次才能穩定。

相關內容