5

I have an equation in an `align' environment. Over one of the equality sign I would like to draw an arrow (slanted, preferred) with the text on the other end being 'This is always true'. How can I use TikZ package in an equation environment like this?

This link contains what I am looking for:

  • 1
    Hi, please provide an MWE in order to reduce typing on our side. Thanks. And maybe draw some picture. I am not sure if I get you right. What is a slanted arrow? What is the "other end"? – LaRiFaRi Jun 10 '14 at 10:57
6

A possiblity:

\documentclass{article}
\usepackage{tikz}
\def\annotateEquality#1{
\tikz[overlay]
  \draw[blue,-latex] (-1.5ex,1.5ex) -- +(.7,.5) node[black,right, draw] {#1};
}

\begin{document}
This is an example:

\[
  X =\annotateEquality{Always true} Y
\]
\end{document}

Result:

Result

Note that, due to the overlay option, the tikz picture "does not take" any space in the result, which is Ok for the horizontal aligment (otherwise the Y will be "pushed" to the right), but can be bad for the vertical alignment, since the box can be too close to the previous paragraph. In this case you have to manually insert some \vskip before the equation.

6

You could also use a tikzmark to mark the appropriate points in the text and then draw the appropriate graphics. The advantage of this is that it separates the content from the annotations. In this specific case the advantage is not huge, but in more complicated situations the same methodology can be applied:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node[baseline] (#1) {};}

\NewDocumentCommand{\DrawBox}{O{} O{} m m}{%
    % #1 = line draw options
    % #2 = node options
    % #3 = tikzmark name
    % #4 = node text
    \begin{tikzpicture}[remember picture, overlay]
        \draw [ultra thick, blue, -latex, shorten >=1pt, #1]
            (#3) ++ (-1.5ex,1.5ex) -- +(.7,.5)
            node [black, right, draw=black, #2] {#4};
    \end{tikzpicture}%
}

\begin{document}
This is an example:
\[
  X =\tikzmark{Point A}  Y
\]
and another example
\[
  X =\tikzmark{Point B}  Z
\]

\DrawBox{Point A}{Always true}
\DrawBox[draw=red][draw=gray, thin, fill=yellow]{Point B}{Sometimes true}
\end{document}
  • @Peter Grill: Thanks very much indeed. Very nice and elegant. – Abhimanyu Arora Jun 11 '14 at 7:30
3

Such a long text would be unreadable in an equation. I would describe this in the surrounding text. Or you define a new symbol for this and describe it in your nomenclature.

% arara: pdflatex

\documentclass{article}
\usepackage{graphicx}
\usepackage{mathtools}
\newcommand\arroweq[1]{\stackrel{\mathclap{\normalfont\scalebox{0.3}{#1}}}{\mathrel{\vec{=}}}}

\begin{document}
  \begin{align}
    x=y\\
    x\arroweq{this is always right} y
    \end{align}

    \begin{center}
    I would recommend to write $x\mathrel{\mathring{=}}y$\\ where $\mathring =$ stands for \emph{this is always right}.
    \end{center}
\end{document}

enter image description here

The mathring is just an example. Use whatever you like. Maybe, there is already a symbol for this.

  • Thanks very much indeed for your kind effort, much appreciated. What I needed was the arrow going from the equality sign and pointing to (or from) the text (say at 45 degrees north-east)...is it possible? – Abhimanyu Arora Jun 10 '14 at 13:58
  • @AbhimanyuArora Is the text somewhere in the image or part of the main text? Please rephrase your OP a bit, to make this question clearer. I am not the TikZ-guy here... sorry. – LaRiFaRi Jun 10 '14 at 14:19
  • @LaRiRaRi: Thanks, have editted my OP to display what I am looking for. – Abhimanyu Arora Jun 10 '14 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.