summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/annotate-equations
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-05-06 03:01:13 +0000
committerNorbert Preining <norbert@preining.info>2023-05-06 03:01:13 +0000
commit507fa9c669d7e4bc2c808f269113c6ced0b18827 (patch)
tree92d0ad38dc9549526803851fa62b4399f03006ac /macros/latex/contrib/annotate-equations
parent3cf2e76fc502cb474081c80838c95ecaba2f386d (diff)
CTAN sync 202305060301
Diffstat (limited to 'macros/latex/contrib/annotate-equations')
-rw-r--r--macros/latex/contrib/annotate-equations/annotate-equations.pdfbin203389 -> 151252 bytes
-rw-r--r--macros/latex/contrib/annotate-equations/annotate-equations.sty13
-rw-r--r--macros/latex/contrib/annotate-equations/annotate-equations.tex72
3 files changed, 78 insertions, 7 deletions
diff --git a/macros/latex/contrib/annotate-equations/annotate-equations.pdf b/macros/latex/contrib/annotate-equations/annotate-equations.pdf
index b29c607771..e7b9b340f2 100644
--- a/macros/latex/contrib/annotate-equations/annotate-equations.pdf
+++ b/macros/latex/contrib/annotate-equations/annotate-equations.pdf
Binary files differ
diff --git a/macros/latex/contrib/annotate-equations/annotate-equations.sty b/macros/latex/contrib/annotate-equations/annotate-equations.sty
index dbdd5f59f5..0c471b13c3 100644
--- a/macros/latex/contrib/annotate-equations/annotate-equations.sty
+++ b/macros/latex/contrib/annotate-equations/annotate-equations.sty
@@ -5,7 +5,7 @@
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{annotate-equations}
- [2023/02/15 v0.2.0 easily annotate equations using TikZ]
+ [2023/03/05 v0.2.1 easily annotate equations using TikZ]
%%% lualatex compatibility, from https://tex.stackexchange.com/a/351520/171664
\RequirePackage{ifluatex}
@@ -55,6 +55,9 @@
label below/.code = {\renewcommand\EAlabelanchor{north}},
}
+\tikzset{annotate equations/arrow/.style={}}
+\tikzset{annotate equations/text/.style={font=\eqnannotationfont}}
+
%%%%% %%%%%%%% %%%%%
@@ -128,13 +131,13 @@
\begin{tikzpicture}[overlay,remember picture,>=stealth,nodes={align=left,inner ysep=1pt},<-]
% default anchor is at center
\node[anchor=\swapNorthSouth{\EAmarkanchor},color=\myEAcolor!85,
- font=\eqnannotationfont,#1
+ annotate equations/text,#1
] % color blended with white to 85%, any (optional) extra args #1
(\eqnannotateCurrentNode) % use counter-based "local node"
at ($(\myEAmarkOne.\EAmarkanchor)!0.5!(\myEAmarkTwo.\EAmarkanchor)$) % centered between the two nodes
{\myEAtext\eqnannotationstrut};
% double arrow to two uses within the equation:
- \draw [<->,color=\myEAcolor] (\myEAmarkOne.\EAmarkanchor) |- ([yshift=0.1ex] \eqnannotateCurrentNode.\EAlabelanchor) -| (\myEAmarkTwo.\EAmarkanchor); % from node 1 via annotation to node 2, with anchor #6 each
+ \draw [<->,color=\myEAcolor, annotate equations/arrow] (\myEAmarkOne.\EAmarkanchor) |- ([yshift=0.1ex] \eqnannotateCurrentNode.\EAlabelanchor) -| (\myEAmarkTwo.\EAmarkanchor); % from node 1 via annotation to node 2, with anchor #6 each
\end{tikzpicture}%
\endgroup% %%% close group again
}
@@ -171,13 +174,13 @@
\def\myEAxshift{\EAxshift{\EAwesteast}}%
\begin{tikzpicture}[overlay,remember picture,>=stealth,nodes={align=left,inner ysep=1pt},<-]
\node[anchor=\swapNorthSouth{\EAmarkanchor} \swapWestEast{\EAwesteast},
- color=\myEAcolor!85,font=\eqnannotationfont,#1] % TODO for some reason, passing #1 through command doesn't work...
+ color=\myEAcolor!85,annotate equations/text,#1] % TODO for some reason, passing #1 through command doesn't work...
% anchor=west: align left edge of text on top of tikzmark in equation
% should be north west for below and south west for above ...
(\eqnannotateCurrentNode) at (\myEAmark.\EAmarkanchor) % \EAmarkanchor north: above the equation, south: below
{\myEAtext\eqnannotationstrut};
\foreach \EAmark in \myEAmarks
- \draw [color=\myEAcolor] (\EAmark.\EAmarkanchor) % arrow from the equation
+ \draw [color=\myEAcolor, annotate equations/arrow] (\EAmark.\EAmarkanchor) % arrow from the equation
% \EAmarkanchor north: above the equation, south: below
|- ([xshift=\myEAxshift,yshift=0.1ex] \eqnannotateCurrentNode.south \EAwesteast);
% - south east: we want line to end at bottom right of annotation text;
diff --git a/macros/latex/contrib/annotate-equations/annotate-equations.tex b/macros/latex/contrib/annotate-equations/annotate-equations.tex
index 26396e679e..5fc0aa6017 100644
--- a/macros/latex/contrib/annotate-equations/annotate-equations.tex
+++ b/macros/latex/contrib/annotate-equations/annotate-equations.tex
@@ -26,15 +26,18 @@
text above listing,
#1}
-\title{\texttt{annotate-equations.sty}}
+\title{\texttt{annotate-equations.sty}, v.0.2.1}
\author{ST John}
\date{\url{https://github.com/st--/annotate-equations}}
+
\begin{document}
\maketitle
-\section{Introduction}
+
+
+%\section{Introduction}
This package is there to make it easier to make annotated equations in \LaTeX, such as in this example:
\begin{LTXexample}[]
@@ -52,6 +55,10 @@ There is still a bit of manual tweaking required (such as adding vertical space
Note that this package relies on TikZ's \texttt{remember picture} option and therefore you have to compile your \LaTeX{} document at least twice to get everything in the right place (or just use \texttt{latexmk}!).
+
+\tableofcontents
+
+
\section{Marking annotation targets within your equation}
\newcommand{\cmdoption}[1]{$\langle$\textit{#1}$\rangle$}
@@ -74,6 +81,7 @@ but this is likely to end up with the arrow tip too close to the target, so you
\end{LTXexample}
\noindent
+
\section{Simple annotations}
\label{sec:annotate}
@@ -128,6 +136,7 @@ One annotation can point to multiple targets, and multiple annotations can point
\noindent
%
+
\section{Double annotations}
\label{sec:annotatetwo}
@@ -146,6 +155,7 @@ One annotation can point to multiple targets, and multiple annotations can point
%
Color is picked from the first of the two nodes.
+
\section{Package options}
\subsection{Size of highlight: shrink to content or always full height}
@@ -222,6 +232,7 @@ By redefining this command, you can change the ``alpha'' value of the highlight:
\noindent
\subsection{Default formatting of annotation labels}
+\label{sec:eqnannotationfont}
\verb|\eqnannotationfont| sets the \texttt{font} field of the TikZ annotation label and can be re-set to change its formatting:
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
@@ -245,6 +256,18 @@ By redefining this command, you can change the ``alpha'' value of the highlight:
\vspace{1em}
\end{LTXexample}
\noindent
+%
+Alternatively, you can also change the style of \verb|annotate equations/text|:
+\begin{LTXexample}[text outside listing,lefthand width=0.5in]
+\tikzset{annotate equations/text/.style={font=\bfseries\small}}
+
+\begin{equation*}
+ \eqnmarkbox[blue]{v}{v}
+\end{equation*}
+\annotate[yshift=-0.5em]{below}{v}{velocity}
+\vspace{1em}
+\end{LTXexample}
+\noindent
\verb|\eqnannotationstrut| is defined to be a strut (zero-width height) to
provide minimum distance between the text and the corresponding arrow line. By
@@ -273,6 +296,32 @@ default it is \verb|\strut|, which has a similar effect to
\end{LTXexample}
+\subsection{Customize style}
+
+You can change the style of the annotation arrow line by setting the style of \verb|annotate equations/arrow|:
+\begin{LTXexample}[text outside listing,lefthand width=0.5in]
+\tikzset{annotate equations/arrow/.style={color=ForestGreen, >=latex', very thick, dashed}}
+
+\begin{equation*}
+ \eqnmarkbox[blue]{size}{s} = \eqnmarkbox[red]{other}{x}
+\end{equation*}
+\annotate[yshift=-0.5em]{below}{size}{The size}
+\annotatetwo[yshift=1em]{above}{size}{other}{the same}
+\end{LTXexample}
+\noindent
+Note that it applies to all \verb|\annotate| and \verb|\annotatetwo| arrows within the scope.
+
+You can also use this to change the arrow direction:
+\begin{LTXexample}[text outside listing,lefthand width=0.5in]
+\begin{equation*}
+ \eqnmarkbox[blue]{size}{s} = \eqnmarkbox[red]{other}{x}
+\end{equation*}
+\tikzset{annotate equations/arrow/.style={->}}
+\annotatetwo[yshift=1em]{above}{size}{other}{one and}
+\tikzset{annotate equations/arrow/.style={<-}}
+\annotatetwo[yshift=-1em]{below, label below}{size}{other}{the same} % note that the "direction" of the arrow is from first to second mark
+\end{LTXexample}
+
\section{Recommendations, tips \& tricks}
\subsection{Use \texttt{\textbackslash{}colorlet} for consistent, easily changeable colors}
@@ -319,4 +368,23 @@ a \mathrel{\tikzmarknode[outer ysep=5pt]{node1}{=}} b
\end{itemize}
+
+\section{Backwards-incompatible changes}
+
+\subsection*{v0.2.0}
+
+\subsubsection*{\texttt{\textbackslash{}eqnannotationtext} removed}
+
+To make it easier to format multiline annotations, version 0.2.0 introduced the \verb|\eqnannotationfont| and \verb|\eqnannotationstrut| (zero-argument) commands (see \cref{sec:eqnannotationfont}).
+
+In exchange, the \verb|\eqnannotationtext| (one-argument) command was removed. To upgrade, replace for example
+\begin{tcblisting}{listing only}
+ \renewcommand{\eqnannotationtext}[1]{\sffamily\tiny#1\strut}
+\end{tcblisting}
+with
+\begin{tcblisting}{listing only}
+ \renewcommand{\eqnannotationfont}{\sffamily\tiny}
+ \renewcommand{\eqnannotationstrut}{\strut}
+\end{tcblisting}
+
\end{document}