4

I need to put diagonal arrows under an equation (the red ones in the picture). I tried using \swarrow \qquad \searrow, but they are not positioned where I need them.

I would prefer not to use tikzmark. Is there another way to achieve this?

Thanks for your help.

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\usepackage{pgfplots}
\usepackage{multicol,array,tabularx,xcolor,enumitem}
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\pagestyle{empty}
%
%
%
%
\definecolor{modra}{cmyk}{1,0,0,0} %%%%DEFINCIE%%%%%BARVY
\definecolor{cerna}{cmyk}{0,0,0,1}
\definecolor{bila}{cmyk}{0,0,0,0}
%
%\color{modra}
%
\begin{document}
\begin{align*}
   S & = \rho \cdot \dfrac{a + b +c}{2}     & S & = \dfrac{a \cdot b}{2} \\
   \rho \cdot \dfrac{a + b +c}{2} & = \dfrac{a \cdot b}{2}  \qquad | \cdot 2 & & \\ 
   18 (a +b+ c ) & = a \cdot b          &  a  & = b  \\
   18 (a + a + c ) & = a \cdot a            &  c^2 & = a^2 + b^2 \\
   18 (2a + c ) & = a^2             &  c^2 & = a^2 + a^2 = 2a^2 \\
   36 a + 18 c  & = a^2         &  c & = \sqrt{2a^2} = a \sqrt{2} \\
   36 a + 18  a \sqrt{2}  & = a^2           &  & \\
   a^2  - 36 a - 18  a \sqrt{2} & = 0       &  & \\
   a \left( a   - 36  - 18   \sqrt{2} \right) & = 0     &  & \\
 \Large \swarrow \qquad \searrow
\end{align*}
%
%
\end{document}

5
  • 4
    Why would you not use tikzmark? Commented 18 hours ago
  • Tikzmark would probably work well, but for this situation it feels unnecessarily complex. I’d prefer to use something lighter if possible? Commented 17 hours ago
  • 3
    Unrelated \usepackage[utf8]{inputenc} is useless now. Commented 17 hours ago
  • 1
    @jlab This is only a part of the code; I do need the package. If it’s confusing, I can remove it from the question. :) Commented 16 hours ago
  • No, you don't need it anymore. This is now the default (see the link in my previous comment). Commented 16 hours ago

3 Answers 3

6

Since you want to avoid tikzmark, you can use the standard picture environment. It may require some fine-tuning for placement.

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{multicol,array,tabularx,xcolor,enumitem}
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\pagestyle{empty}

\definecolor{modra}{cmyk}{1,0,0,0} %%%%DEFINCIE%%%%%BARVY
\definecolor{cerna}{cmyk}{0,0,0,1}
\definecolor{bila}{cmyk}{0,0,0,0}
%
%\color{modra}
%

\begin{document}

\setlength{\unitlength}{1mm}
\begin{picture}(100,80)
\put(0,80){
\begin{minipage}[t]{\columnwidth}
\begin{align*}
   S & = \rho \cdot \dfrac{a + b +c}{2}     & S & = \dfrac{a \cdot b}{2} \\
   \rho \cdot \dfrac{a + b +c}{2} & = \dfrac{a \cdot b}{2}  \qquad | \cdot 2 & & \\ 
   18 (a +b+ c ) & = a \cdot b          &  a  & = b  \\
   18 (a + a + c ) & = a \cdot a            &  c^2 & = a^2 + b^2 \\
   18 (2a + c ) & = a^2             &  c^2 & = a^2 + a^2 = 2a^2 \\
   36 a + 18 c  & = a^2         &  c & = \sqrt{2a^2} = a \sqrt{2} \\
   36 a + 18  a \sqrt{2}  & = a^2           &  & \\
   a^2  - 36 a - 18  a \sqrt{2} & = 0       &  & \\
   a \left( a   - 36  - 18   \sqrt{2} \right) & = 0     &  & \\
\end{align*}
\end{minipage}
\thicklines
\put(-114,-67){\color{red}\vector(-1,-1){7}}
\put(-98,-67) {\color{red}\vector(1,-1){7}}
}
\end{picture}

\end{document}

5

Here is a simple solution with tikzmark:

  • using \tikzmarknode
  • commenting out unused parts and colors
\documentclass[11pt,a4paper]{article}
%\usepackage[utf8]{inputenc}
%\usepackage[czech]{babel}
%\usepackage[T1]{fontenc}
%\usepackage{pgfplots}
%\usepackage{multicol,array,tabularx,xcolor,enumitem}
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\pagestyle{empty}
% ~~~ let's use Tikz ~~~~~~~~~~~~~~~
\usepackage{tikz}
\usetikzlibrary{tikzmark}   % to draw over the equations
\usetikzlibrary{arrows.meta}% for nicer arrow tips
%
%
%
%
%\definecolor{modra}{cmyk}{1,0,0,0} %%%%DEFINCIE%%%%%BARVY
%\definecolor{cerna}{cmyk}{0,0,0,1}
%\definecolor{bila}{cmyk}{0,0,0,0}
%
%\color{modra}
%
\begin{document}
\begin{align*}
   S & = \rho \cdot \dfrac{a + b +c}{2}     & S & = \dfrac{a \cdot b}{2} \\
   \rho \cdot \dfrac{a + b +c}{2} & = \dfrac{a \cdot b}{2}  \qquad | \cdot 2 & & \\ 
   18 (a +b+ c ) & = a \cdot b          &  a  & = b  \\
   18 (a + a + c ) & = a \cdot a            &  c^2 & = a^2 + b^2 \\
   18 (2a + c ) & = a^2             &  c^2 & = a^2 + a^2 = 2a^2 \\
   36 a + 18 c  & = a^2         &  c & = \sqrt{2a^2} = a \sqrt{2} \\
   36 a + 18  a \sqrt{2}  & = a^2           &  & \\
   a^2  - 36 a - 18  a \sqrt{2} & = 0       &  & \\
   \tikzmarknode{A}{a} \left( a   - \tikzmarknode{nmb}{36}  - 18   \sqrt{2} \right) & = 0     &  & \\
% \Large \swarrow \qquad \searrow
\end{align*}

\begin{tikzpicture}[
    remember picture, overlay,          % needed with tikzmark
    arr/.style={red,->,line width=2pt}, % arrow
    >={Stealth},                        % other tip
]
    \draw[arr] ([yshift=-2mm]A.south west) -- +(-135:1);
    \draw[arr] ([yshift=-2mm]nmb.south) -- +(-45:1);
\end{tikzpicture}
%
And so we continue \dots
%
\end{document}

2

I would instead recommend tikzmark, but here is a try, using zero sized boxes and a tabular to position the arrow and an optional content

\NewDocumentCommand{\annotate} { s m O{} } {%
  \IfBooleanTF {#1}
    {% point right
      #2%
      \raisebox{-\height}[0pt][0pt]
        {%
          \rlap
            {%
              \begin{tabular}{@{} r @{}}
                \Large $\searrow$ \\
                \clap{#3}
              \end{tabular}%
            }%
        }
    }
    {% point left
      \raisebox{-\height}[0pt][0pt]
        {%
          \llap
            {%
              \begin{tabular}{@{} l @{}}
                \Large $\swarrow$ \\
                \clap{#3}
              \end{tabular}%
            }%
        }
      #2%
    }%
}

With a star, the arrow points on the left, without, on the right. The optional argument is centered under the arrow.

Example:

\documentclass[11pt,a4paper]{article}

\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts,amssymb,mathrsfs}
\usepackage{graphicx}

\NewDocumentCommand{\annotate} { s m O{} } {%
  \IfBooleanTF {#1}
    {% point right
      #2%
      \raisebox{-\height}[0pt][0pt]
        {%
          \rlap
            {%
              \begin{tabular}{@{} r @{}}
                \Large $\searrow$ \\
                \clap{#3}
              \end{tabular}%
            }%
        }
    }
    {% point left
      \raisebox{-\height}[0pt][0pt]
        {%
          \llap
            {%
              \begin{tabular}{@{} l @{}}
                \Large $\swarrow$ \\
                \clap{#3}
              \end{tabular}%
            }%
        }
      #2%
    }%
}

\begin{document}


Dummy text before\dots
\begin{align*}
   S & = \rho \cdot \dfrac{a + b +c}{2}     & S & = \dfrac{a \cdot b}{2} \\
   18 (a +b+ c ) & = a \cdot b          &  a  & = b  \\
  \dots\\
   \annotate{a} \left( a   - \annotate*{36}  - 18   \sqrt{2} \right) & = 0     &  & \\
\end{align*}
\dots and after.

\bigskip

Dummy text before\dots
\begin{align*}
   S & = \rho \cdot \dfrac{a + b +c}{2}     & S & = \dfrac{a \cdot b}{2} \\
   18 (a +b+ c ) & = a \cdot b          &  a  & = b  \\
  \dots\\
   \annotate{a}[this is $a$] \left( a   - \annotate*{36}[this is 36]  - 18   \sqrt{2} \right) & = 0     &  & \\
\end{align*}
\dots and after.

\end{document}

1
  • 1
    Nice approach +1 Commented 16 hours ago

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.