Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't layer eqnmarkbox with eqnmark (can't make hierarchical labels) #20

Open
codercahol opened this issue Jul 13, 2023 · 4 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@codercahol
Copy link

codercahol commented Jul 13, 2023

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}
@st-- st-- added enhancement New feature or request help wanted Extra attention is needed labels Jul 18, 2023
@st--
Copy link
Owner

st-- commented Jul 18, 2023

(Next time, it would be great if you could provide the code for reproducing your issue as a complete, self-contained and compilable "minimal reproducible example"! It's much easier if I can simply copy&paste and compile to see what the issue is, instead of first having to figure out what to put into the preamble...)

@st--
Copy link
Owner

st-- commented Jul 18, 2023

I had to fix your example a bit (the node labels are term1 and term2, not A and B), but then it seems to work fine for me:
image

Edit: just realized it was the annotation text, not the background highlighting, that wasn't working. Ok, this is actually a bug. I think the issue might be the internal handling of the node counter 🤔 I'll have to get back to this after I'm back from holidays though.

@st-- st-- added bug Something isn't working and removed enhancement New feature or request labels Jul 18, 2023
@stevenwalton
Copy link

I'm also facing this bug as well as just issues trying to get the label below...
Here's a full example

\documentclass[border={0pt 23pt 12pt 20pt}]{standalone}
% <left bottom right top>
% Needed because annotate markings will get chopped off....
% for tight cropping use 0pt 15pt 12pt 20pt

\usepackage{amsmath} % give us equation*
\usepackage{annotate-equations}

\begin{document}
    \begin{equation*}
        PP(p) = 2^{
            \eqnmarkbox[red]{entropy}
                {
                    \tikzmarknode{p1}{p(x)} \log_2 \tikzmarknode{p2}{p(x)}
                }
        }
    \end{equation*}
    \annotate{below, label below}{entropy}{\textbf{Entropy ($H(x)$)}}
    \annotate{}{p1,p2}{\textbf{Probability}}
\end{document}

The result is usually this

Screenshot 2024-08-21 at 11 35 55 PM

If I compile with pdflatex -synctex=1 -interaction=nonstopmode --shell-escape perplexity.tex I get this

Screenshot 2024-08-21 at 11 38 56 PM

There is also an error
! Missing $ inserted.
<inserted text>
                            $
l.12                        }

<inserted text>
                            $
l.12                        }

! LaTeX Error: Bad math environment delimiter.

See the LaTeX manual or LaTeX companion for explanation.
Type H <return>   for immediate help.
 ...

l.13        \end{equation*}

If I run the exact same command a second time I get something much closer (the same error occurs fwiw)

Screenshot 2024-08-21 at 11 42 51 PM

Note that Entropy is still not below the line. I even face this issue when not nesting.

After like the 3rd or 4th compile it tends to work (with same errors)

Screenshot 2024-08-21 at 11 54 16 PM

(this image has the commented border and a yshift=-1em on entropy and yshift=1em on probability)

@stevenwalton
Copy link

Actually I wrote that last one too quickly. I forgot I was debugging and didn't even add the exponent back

\documentclass[border={0pt 23pt 12pt 20pt}]{standalone}
%\documentclass[border={0pt 23pt 12pt 20pt},density=300,outext=.png, background=white,flatten]{standalone}
% left bottom right top

\usepackage{amsmath} % Needed for the * in equation
\usepackage{annotate-equations}

\begin{document}
    \begin{equation*}
        PP(p) = 2^{
            \eqnmarkbox[red]{entropy}{
                \tikzmarknode{p1}{p(x)} \log_2 \tikzmarknode{p2}{p(x)}
            }
        }
   \end{equation*}
   \annotate[yshift=-1em]{below, label below}{entropy}{\textbf{Entropy ($H(x)$)}}
   \annotate[yshift=1em]{}{p1,p2}{\textbf{Probability}}
\end{document}

Here's the full error log
$ rm *.aux *.log *.pdf
$ pdflatex -synctex=1 -interaction=nonstopmode --shell-escape perplexity.tex
This is pdfTeX, Version 3.141592653-2.6-1.40.26 (TeX Live 2024) (preloaded format=pdflatex)
 \write18 enabled.
entering extended mode
(./perplexity.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-02-20>
(/usr/local/texlive/2024/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2022/10/10 v1.3b Class to compile TeX sub-files stan
dalone
(/usr/local/texlive/2024/texmf-dist/tex/latex/tools/shellesc.sty)
(/usr/local/texlive/2024/texmf-dist/tex/generic/iftex/ifluatex.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/iftex/iftex.sty))
(/usr/local/texlive/2024/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(/usr/local/texlive/2024/texmf-dist/tex/latex/standalone/standalone.cfg)
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/usr/local/texlive/2024/texmf-dist/tex/latex/base/size10.clo)))
(/usr/local/texlive/2024/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2024/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2024/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/amsmath/amsopn.sty))
(./annotate-equations.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.te
x)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
) (/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfkeyslibraryfil
tered.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.d
ef
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-p
df.def)))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.
code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.
code.tex)) (/usr/local/texlive/2024/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/local/texlive/2024/texmf-dist/tex/latex/graphics/mathcolor.ltx))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.
tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic
.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigo
nometric.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.rando
m.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.compa
rison.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.
code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round
.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.
code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integ
erarithmetics.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)
) (/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.co
de.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconst
ruct.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage
.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.co
de.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicst
ate.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransform
ations.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.cod
e.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.c
ode.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathproce
ssing.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.co
de.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.cod
e.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.cod
e.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.
code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.co
de.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretranspare
ncy.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.
code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.
tex)))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.cod
e.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.
tex)
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-0-65.sty)
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version
-1-18.sty))
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex)
) (/usr/local/texlive/2024/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex))

(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.cod
e.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothan
dlers.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.cod
e.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarytopaths.code.tex)))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarybackgrounds.code.tex)
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryarrows.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/pgflibraryarrows.
code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.geometric.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.geometric.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.misc.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.misc.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.symbols.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.symbols.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.arrows.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.arrows.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.callouts.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.callouts.code.tex))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibraryshapes.multipart.code.tex
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/libraries/shapes/pgflibrary
shapes.multipart.code.tex)))
(/usr/local/texlive/2024/texmf-dist/tex/latex/tikzmark/tikzlibrarytikzmark.code
.tex (/usr/local/texlive/2024/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def))
(/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
 (/usr/local/texlive/2024/texmf-dist/tex/latex/l3packages/xparse/xparse.sty))
(/usr/local/texlive/2024/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarycalc.code.tex)) (./perplexity.aux)
(/usr/local/texlive/2024/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2024/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2024/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Missing $ inserted.
<inserted text> 
                $
l.10         PP(p) = 2^
                       { \eqnmarkbox[red]{entropy} { \tikzmarknode{p1}{p(x)}...

! Missing $ inserted.
<inserted text> 
                $
l.11    \end{equation*}
                       

! Package pgf Error: No shape named `p1' is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 ...yshift=1em]{}{p1,p2}{\textbf{Probability}}
                                                  

! Package pgf Error: No shape named `p1' is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 ...yshift=1em]{}{p1,p2}{\textbf{Probability}}
                                                  

! Package pgf Error: No shape named `p2' is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 ...yshift=1em]{}{p1,p2}{\textbf{Probability}}
                                                  
[1{/usr/local/texlive/2024/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./perplexity.aux)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

 )
(see the transcript file for additional information)</usr/local/texlive/2024/te
xmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></usr/local/texlive/2024/texm
f-dist/fonts/type1/public/amsfonts/cm/cmmi8.pfb></usr/local/texlive/2024/texmf-
dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/local/texlive/2024/texmf-di
st/fonts/type1/public/amsfonts/cm/cmr5.pfb></usr/local/texlive/2024/texmf-dist/
fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/local/texlive/2024/texmf-dist/fon
ts/type1/public/amsfonts/cm/cmr8.pfb></usr/local/texlive/2024/texmf-dist/fonts/
type1/public/amsfonts/cm/cmssbx10.pfb>
Output written on perplexity.pdf (1 page, 63642 bytes).
SyncTeX written on perplexity.synctex.gz.
Transcript written on perplexity.log.

If I make sure to delete the pdf, aux, and log I can get this image, but the second compile will always return what's above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants