TeX - LaTeX Asked by The Great Seo on August 25, 2021
I tried to use tikz and https://tex.stackexchange.com/a/270007/161413 to color arrows with several colors.
But I was also using mathtools, and found out that tikz and mathtools are not compatible as they both change the definition of :
.
I applied the solution in https://tex.stackexchange.com/a/89470/161413 but still it does not work.
Here is my MWE (I am using XeLaTeX):
documentclass{article}
usepackage[
a4paper,
margin=30mm
]{geometry}
usepackage{amsmath, amssymb, amsthm}
usepackage{tikz}
usepackage{mathtools} % commenting this line works
usepackage{etoolbox}
makeatletter
AtEndPreamble{
ifnummathcode`:=string"8000
begingrouplccode`~=`:
lowercase{endgroupletmath@colon@meaning~}
else
expandafterletexpandaftermath@colon@meaningstring:
fi
}
AtBeginDocument{
ifnumcatcode`:=active
letcstext@colon@meaning{active@charstring:}
else
expandafterletexpandaftertext@colon@meaningstring:
fi
protecteddeftikz@nonactivecolon{%
ifmmode
expandaftermath@colon@meaning
else
expandaftertext@colon@meaning
fi}
begingrouplccode`~=`:
lowercase{endgrouplet~tikz@nonactivecolon}
}
makeatother
usetikzlibrary{graphs}
usetikzlibrary{positioning}
usetikzlibrary{intersections}
usetikzlibrary{decorations.markings}
newlengthmylen
tikzset{
bicolor/.style n args={2}{
decoration={
markings,
mark=at position 0.5 with {
node[draw=none,inner sep=0pt,fill=none,text width=0pt,minimum size=0pt] {globalsetlengthmylen{pgfdecoratedpathlength}};
},
},
draw=#1,
dash pattern=on 0.5mylen off 0.5mylen,
preaction={decorate},
postaction={
draw=#2,
dash pattern=on 0.5mylen off 0.5mylen,dash phase=0.5mylen
},
}
}
begin{document}
begin{tikzpicture}
node (bbb) at (0,0) {bbb};
node (baa) at (150:3) {baa};
draw[->, bicolor={cyan}{red!80!black}]
(baa) to[out=-80,in=150] (bbb);
end{tikzpicture}
end{document}
The tikz code is faulty. It uses globalsetlength
. This relies on a side effect which breaks if the calc
package is loaded. If you use globalmylen
instead it works:
documentclass{article}
usepackage[
a4paper,
margin=30mm
]{geometry}
usepackage{amsmath, amssymb, amsthm}
usepackage{tikz}
%
usepackage{etoolbox}
usepackage{mathtools}
usetikzlibrary{graphs}
usetikzlibrary{positioning}
usetikzlibrary{intersections}
usetikzlibrary{decorations.markings}
newlengthmylen
tikzset{
bicolor/.style n args={2}{
decoration={
markings,
mark=at position 0.5 with {
node[draw=none,inner sep=0pt,fill=none,text width=0pt,minimum size=0pt] {globalmylenpgfdecoratedpathlength};
},
},
draw=#1,
dash pattern=on 0.5mylen off 0.5mylen,
preaction={decorate},
postaction={
draw=#2,
dash pattern=on 0.5mylen off 0.5mylen,dash phase=0.5mylen
},
}
}
begin{document}
begin{tikzpicture}
node (bbb) at (0,0) {bbb};
node (baa) at (150:3) {baa};
tracingmacros=1
draw[->, bicolor={cyan}{red!80!black}]
(baa) to[out=-80,in=150] (bbb);
end{tikzpicture}
end{document}
Correct answer by Ulrike Fischer on August 25, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP