st-- / annotate-equations Goto Github PK
View Code? Open in Web Editor NEWLaTeX package and annotated examples for annotating equations using TikZ.
License: MIT License
LaTeX package and annotated examples for annotating equations using TikZ.
License: MIT License
When the \annotate
command is used outside the math environment (as the examples use it), and extra line/paragraph is added after the math environment.
If instead one puts the \annotate
command inside the math environment, such before \end{equation}
, then no extra line is added. The user then needs to add \vspace
explicitly to add spacing for the annotation labels that are rendered below
, which is consistent with the requirements for those rendered above
.
Note the line 223
.
Some text before.
\begin{equation}
\eqnmark[red]{node1}{x} = \eqnmark[blue]{node2}{y}
\end{equation}
\annotate[yshift=0.2em]{above,left}{node1}{fubar X}
\annotate[yshift=0.2em]{above,right}{node2}{hello Y}
Some text after.
Some text before.
\begin{equation}
\eqnmark[red]{node1}{x} = \eqnmark[blue]{node2}{y}
\annotate[yshift=0.2em]{above,left}{node1}{fubar X}
\annotate[yshift=0.2em]{above,right}{node2}{hello Y}
\end{equation}
Some text after.
Some text before.
\begin{equation}
\eqnmark[red]{node1}{x} = \eqnmark[blue]{node2}{y}
\end{equation}
Some text after.
with standalone it doesn't work
\documentclass{standalone}
\usepackage{amsmath}
\usepackage{annotate-equations}
\begin{document}
\renewcommand{\eqnhighlightheight}{\mathstrut}
\begin{equation*}
\eqnmark{post}{p(\theta | D)} = \frac{\eqnmark{lik}{p(D|\theta)}
\eqnmark{prior}{p(\theta)}} {\eqnmark{marglik}{p(D)}}
\end{equation*}
\annotate[yshift=2.5em]{above,right}{lik}{likelihood}
\annotate[yshift=1em]{above,right}{prior}{prior}
\annotate[yshift=1em]{above,left}{post}{posterior}
\annotate[yshift=-1em]{below,right}{marglik}{marginal likelihood}
\end{document}
At least the package pgf
(for tikz
) and tikzmark
are required to use annotate-equations
. It should be a good idea to declare the dependency on these packages by listing them in DEPENDS.txt
(see the usage).
There are other tools to locate all dependencies, but I did not try.
If the equation to be labeled is on the bottom of one page and LaTeX does a pagebreak right after the equation, the labels will show up in the next page with no error messages. e.g.
\[ ... \eqnmarkbox[...]{...} ...
\]
% page flip here
\annotate{...} % shows up on the next page
This can be solved by inserting a \pagebreak
right after \annotate
.
Hi. Thank you very much for this nice package, it is quite useful for me.
I believe I have found a bug in the pdf documentation. At some point, you mention that to change the font size/style, the following command should be used:
\renewcommand{\eqnannotationfont}{\sffamily\tiny}
When I do that, the compiler complains that the command \eqnannotationfont doesn't exist. When I check the sty file available in my installation (using MikTeX in Windows, if that matters) I can confirm that it really doesn't.
To change the font, this is the command that I had to include:
\renewcommand{\eqnannotationtext}[1]{\sffamily\tiny#1\strut}
By the way, it would be nice to have a way to change the color of the annotation (arrow and text) without changing the color of the equation or having to add a box around it. I did this by defining \renewcommand{\eqnhighlightshade}{0}
, but this is a global option (for all annotations). There could be a way to do it for individual annotations. If you think this is interesting, I can try to implement and make a pull request.
Could not figure out how to get the combination of \EAlabelanchor
and pgf math to work, either it complained about \EAlabelanchor \EAwesteast
fusing into southeast
, or with any attempts at fixing it it wouldn't compile anymore.
Every once in a while it dislocates a piece of the equation inapropriately, like the equal sign on the second one:
\documentclass{report}
\usepackage{annotate-equations}
\begin{document}
\[
a \tikzmarknode{node1}{=} b
\]
\annotate[yshift=-1em]{below}{node1}{change of variables}
\[
\int_0^{\infty}F_X(x)dx =\int_0^{\infty}F_X(-x)dx \tikzmarknode{node2}{=} \int^0_{-\infty}F_X(x)dx.
\]
\annotate[yshift=-1em]{below}{node2}{change}
\end{document}
A solution is suggested here.
For exemple, with \annotatetwo
, we obtain a <------->
arrow (with corners). Currently, I don't see how to pass an tikz option to the command in order to have the tip only in one side (or to have dotted or dashed or thick lines).
I thought I could use the annotate-equations
package to answer this question:
https://tex.stackexchange.com/questions/676227/how-to-draw-a-simple-curved-arrow-inside-of-an-equation
But currently, I cannot, because in the picture illustrating the question, the tip is only in one side, and \annotatetwo
create an arrow with two tips, one in each side.
Would be nice to be able to "connect" two boxes in subsequent lines with the same annotation. That would require the arrow to connect below one box, but above another.
environment : overleaf
compiler=lualatex
or xelatex
\begin{equation*}
\eqnmarkbox[blue]{node1}{e_q^n}
\eqnmark[red]{node2}{f(x)}
\tikzmarknode{node3}{kT}
\end{equation*}
\tikzset{annotate equations/arrow/.style={->}}
\annotatetwo[yshift=1em]{above}{node1}{node3}{text}
%\annotate[yshift=1em]{left}{node1}{my}
\annotate[yshift=-0.5em]{below, left}{node2}{annotation}
\annotate[yshift=-0.1em]{below, label below}{node3}{text}
though I changed the default settings, the arrow lines compiled still keep the original style. \tikzset{annotate equations/arrow/. style = {color=ForestGreen, >=latex', very thick, dashed}}
also has no effect.
Hi, thanks for the amazing package! This is a total game changer.
One thing I've been struggling with is how to use this in a quarto file that renders to an HTML file.
Tried a number of different strategies, but to no avail:
Is this something you've had any success with in the past?
Thanks again!
As a positioning solution using TikZ, it needs to be processed twice before getting everything in the proper place. I have not seen that mentioned in the manual. My suggestion is for right afte the text:
There is still a bit of manual tweaking required (such as adding vertical space before/after the
equation), but hopefully this package will already make it a bit more inviting to annotate your equations!
on the top of the first page.
I want to create layered/hierarchical labels. For example, a group of terms within parentheses are the "background contribution" and the individual terms might be the "first order" and "trailing order". The overbar/curly brace shown in the original demo by Sibin covers this usecase but there is no easy way of replicating that with the current package.
Right now, in the following cod the annotation for \eqnmarkbox{Background}
does not appear, only the colored box appears:
\begin{equation}
y(x) = \eqnmarkbox[blue]{Background}{
(\eqnmark[red]{term1}{A} + \eqnmark[green]{term2}{B})
}
\end{equation}
\annotate[yshift=-1em]{below}{Background}{background term}
\annotate[yshift=0.5em]{left}{A}{first term}
\annotate[yshift=1em]{}{B}{second term}
It could be useful to allow the setting of background and text colours for\eqnmarkbox
.
Thanks for your package.
The arrow with the comment sometimes invade a sign in the middle of the formula.
\documentclass{report}
\usepackage{annotate-equations}
\begin{document}
\[
\sum_{i=1}^n E(X_i|S=s) \mathrel{\tikzmarknode{node5}{=}} E\left(\sum_{i=1}^n X_i|S=s\right)
\]
\annotate[yshift=-3.5em]{above}{node5}{por linearidade}
\end{document}
The manual mentions (mora than once) that it should be processed with pdflatex
or lualatex
. I have use it with xelatex
with equal results. Why is it xelatex not mentioned?
Is there any way of getting e.g. \sffamily
to apply across multiple lines?
When I need to compile references and citations in a beamer project using Bibtex
no matter how many times I compile withxelatex
, the comments don't get put in the right place. I've tried "xe->bib->xe->xe", "xe->bib->xe->xe->xe->xe" etc.
To whom it may concern,
I attempted to load this package on Overleaf and run the examples, but the annotate functions didn't work correctly, apparently because they couldn't find the nodes in the equation.
If you need any further information (e.g. my preamble) to replicate this result, please let me know. However, I noticed it does work with a test project, when I pull in the dependencies from the .sty file. Any reason why that would work?
Thanks for your help, I greatly appreciate it.
Best,
John
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.