loopspace / tikzmark

The dread tikzmark arrives on github
14 stars 3 forks source link

highlighting keys don't work as expected #16

Open amunn opened 1 year ago

amunn commented 1 year ago

Hi Andrew, this issue is based on this Stackexchange question.

It seems there are two problems, at least as I understand the documentation: first, the highlighting keys seem to require the highlighter/ prefix rather than just being specified by name alone. Second, the scope of setting the keys in this way is global, so keys set in one \Start ... \StopHighligting domain persist into the the next one.

\documentclass{article}
\usepackage[x11names,dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzmarklibrary{highlighting}

\begin{document}

The sun was shining on the sea, shining with all its might.
\StartHighlighting[
fill=cyan!50,
highlighter/initial height=.5ex,
%initial height=1ex, % fails
highlighter/final height=.5ex,
% final height=1ex % fails
]
 And this was very odd because it was the middle of the night.
 \StopHighlighting

\bigskip
\StartHighlighting[fill=cyan!20] % keys are not local as a result
 And this was very odd because it was the middle of the night.
\StopHighlighting
\end{document}
loopspace commented 12 months ago

Thanks for bringing that question to my attention - I'd missed that.

I tend to put keys for my packages in their own directory, feels like that's the way it ought to be done. But I can see an argument that the \StartHighlighting command ought to invoke that directory automatically (with the correct error handling to drop any unknown keys back to TikZ). That's a good idea.

The global issue is because the highlighting is actually implemented in the header/footer code so the options need to persist into the header and out of any environment in which they are declared. There probably is a way to be a little more careful to ensure that a set of keys only applies to a given highlighting. I'll take a look.

loopspace commented 11 months ago

First attempt at fixing both issues: https://github.com/loopspace/tikzmark/commit/5edae280803ca5e4ec2a1f5fcac5108c95bf9c08