1

I have the following graphics including an arrow ending with a triangle:

\documentclass[margin=0.5mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}
\node[draw=white] (1) at (4,0) {AA};
\node[draw=white] (2) at (0,4) {BB};
\draw[black, arrows={|-Triangle[angle=45:10pt,black,fill=black]}] (1) -- (2);
\end{tikzpicture}
\end{document}

How to change it so as the arrow will end with a question mark instead of the triangle?

2 Answers 2

0

My solution is similar to that of ferahfeza. My train of thought was the following:

With the help of \usetikzlibrary{calc} you can exactly calculate a point on a given route. We take advantage of this:

\documentclass[margin=0.5mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node[draw=white] (1) at (4,0) {AA};
\node[draw=white] (2) at (0,4) {BB};
%\draw[black, arrows={|-Triangle[angle=45:10pt,black,fill=black]}] (1) -- (2);

\draw (1) -- (2);
\node[fill=white,draw,circle,inner sep=1pt] at ($(4,0)!.92!(0,4)$) {?}; % You can remove the node options if you want
\end{tikzpicture}
\end{document}
1
  • Thanks, this option is the most suitable for me, although the other two are also good.
    – wiktoria
    Jun 17, 2018 at 15:21
3

I suspect you want the question mark to point along the line at the end. You could use the sloped to align the question mark perpendicular to the line and then rotate it 90 degrees to make it parallell. Also you'd need to reposition the question mark as it would have it's anchor point in the middle.

\documentclass[margin=0.5mm]{standalone}
\usepackage{tikz}
\begin{document}
  % Get height of question mark
  \newbox\qbox
  \setbox\qbox\hbox{?}
  \edef\qmarkHeight{\the\ht\qbox}
  \begin{tikzpicture}
    \node[draw=white] (1) at (4,0) {AA};
    \node[draw=white] (2) at (0,4) {};
    \node[above left] at (2) {BB};
    \draw[black, arrows={|-}] (1) -- (2) node[sloped, at end, rotate=90, yshift=\qmarkHeight/2]{?};
  \end{tikzpicture}
\end{document}

Which produces this "tip": question mark arrow tip

Additionally you can make it a style (\draw[questionmark]...) using decorations, as per this answer:

\documentclass[margin=0.5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
  % Get height of question mark
  \newbox\qbox
  \setbox\qbox\hbox{?}
  \edef\qmarkHeight{\the\ht\qbox}
  \begin{tikzpicture}
    \tikzset{questionmark/.style={
          postaction={
              decorate,decoration={
                  markings,mark=at position 1 with {
                      \node[at end, rotate=-90, yshift=\qmarkHeight/2]{?};
                    }
                }
            }
        }
    }
    \node[draw=white] (1) at (4,0) {AA};
    \node[draw=white] (2) at (0,4) {};
    \node[above left] at (2) {BB};
    \draw[black, arrows={|-}, questionmark] (1) -- (2);
  \end{tikzpicture}
\end{document}

Which produces an (almost) identical result.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .