diff options
author | Karl Berry <karl@freefriends.org> | 2023-05-06 19:54:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-05-06 19:54:55 +0000 |
commit | f6472cb8ab8ddf29e7b654e161e362e9e1bebc39 (patch) | |
tree | 832f13e1e42635774238353a5ce608c8308bc139 | |
parent | 4a7397a5588c0ac4552d95eb3361cf49b716709b (diff) |
annotate-equations (6may23)
git-svn-id: svn://tug.org/texlive/trunk@67031 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.pdf | bin | 203389 -> 151252 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.tex | 72 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/annotate-equations/annotate-equations.sty | 13 |
3 files changed, 78 insertions, 7 deletions
diff --git a/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.pdf b/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.pdf Binary files differindex b29c6077716..e7b9b340f22 100644 --- a/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.pdf +++ b/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.pdf diff --git a/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.tex b/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.tex index 26396e679e1..5fc0aa60175 100644 --- a/Master/texmf-dist/doc/latex/annotate-equations/annotate-equations.tex +++ b/Master/texmf-dist/doc/latex/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} diff --git a/Master/texmf-dist/tex/latex/annotate-equations/annotate-equations.sty b/Master/texmf-dist/tex/latex/annotate-equations/annotate-equations.sty index dbdd5f59f5a..0c471b13c30 100644 --- a/Master/texmf-dist/tex/latex/annotate-equations/annotate-equations.sty +++ b/Master/texmf-dist/tex/latex/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; |