我需要数字下方指向正确方向的箭头的代码。我在网上查找了命令,我所知道的\uarrow
都是向左而不是向右的。:
谢谢 Hendrik。我的问题解决了!
答案1
先前的解决方案在数字下方添加箭头允许提供选项,\DrawArrow
您可以使用这些选项来反转箭头的方向。您可以\DrawArrow
从以下方式更改所有后续调用的箭头样式:
\tikzset{BottomArrowStyle/.style={thin, -stealth}}
该选项从左到右-stealth
绘制一个样式箭头,以stealth
\tikzset{BottomArrowStyle/.style={thin, stealth-}}
它从右到左绘制箭头,如右侧第一行所示。
或者,您可以<-
为每个指定\DrawArrow
方向,然后可以根据需要混合搭配方向,如第二行右侧所示,其中和olive
以magenta
相反的方向绘制。我认为您不是想这样做,而是为了说明其用途。
代码:
\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}
%% Set these if you want to globally atler the arrow styles
%% for the top and bottom arrows.
\tikzset{TopArrowStyle/.style={}}%
\tikzset{BottomArrowStyle/.style={}}%
\newcommand{\tikzmark}[2]{%
\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {\phantom{#2}};#2%
}
\newcommand*{\XShift}{0.5ex}%
\newcommand*{\ArcDistance}{0.075cm}%
\newcommand*{\OutAngle}{}%
\newcommand*{\InAngle}{}%
\newcommand*{\AnchorPoint}{}%
\newcommand*{\ShortenBegin}{}%
\newcommand*{\ShortenEnd}{}%
%
\NewDocumentCommand{\DrawArrow}{s O{} m m}{%
\IfBooleanTF {#1} {% starred variant - draw arrows below
\renewcommand*{\OutAngle}{-95}%
\renewcommand*{\InAngle}{-85}%
\renewcommand*{\AnchorPoint}{south}%
\renewcommand*{\ShortenBegin}{-3.5pt}%
\renewcommand*{\ShortenEnd}{-3.5pt}%
\tikzset{Arrow Style/.style={BottomArrowStyle}}%
}{% non-starred - draw arrows above
\renewcommand*{\OutAngle}{95}%
\renewcommand*{\InAngle}{85}%
\renewcommand*{\AnchorPoint}{north}%
\renewcommand*{\ShortenBegin}{-3.5pt}%
\renewcommand*{\ShortenEnd}{-3.5pt}%
\tikzset{Arrow Style/.style={TopArrowStyle}}%
}%
\begin{tikzpicture}[overlay,remember picture]
\draw[
->, thick, distance=\ArcDistance,
shorten <=\ShortenBegin, shorten >=\ShortenEnd,
out=\OutAngle, in=\InAngle, Arrow Style, #2
]
($(#3.\AnchorPoint)+(2.0*\XShift,0)$) to
($(#4.\AnchorPoint)+(0.4*\XShift,0)$);
\end{tikzpicture}%
}
\begin{document}
\tikzset{BottomArrowStyle/.style={thin, -stealth}}% change arrow style
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[red]{One}{One}%
\DrawArrow*[brown]{Two}{Two}%
\DrawArrow*[blue]{Three}{Three}%
%
\hspace*{0.25cm}%
%
\tikzset{BottomArrowStyle/.style={thin, stealth-}}% change arrow style
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[olive]{One}{One}%
\DrawArrow*[green]{Two}{Two}%
\DrawArrow*[magenta]{Three}{Three}%
\tikzset{BottomArrowStyle/.style={}}% restore to default
\bigskip
10.\tikzmark{ThreeB}{5}\tikzmark{TwoB}{6}\tikzmark{OneB}{6}%
\DrawArrow*[red]{OneB}{OneB}%
\DrawArrow[brown]{TwoB}{TwoB}%
\DrawArrow*[blue]{ThreeB}{ThreeB}%
%
\hspace*{0.25cm}%
%
10.\tikzmark{ThreeB}{5}\tikzmark{TwoB}{6}\tikzmark{OneB}{6}%
\DrawArrow*[olive,<-]{OneB}{OneB}%
\DrawArrow[green,<-]{TwoB}{TwoB}%
\DrawArrow*[magenta,->]{ThreeB}{ThreeB}%
\bigskip
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[red,in=-85, out=-95, distance=0.2cm]{One}{Three}%
%
\hspace*{0.25cm}%
%
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[magenta,in=-85, out=-95, distance=0.2cm, <-]{One}{Three}%
\end{document}