TeX - LaTeX Asked on March 2, 2021
I’m trying to implement a colored footnote style with Tikz in Context. After some fine tuning according to the specific font in use, I’ve gotten something like this:
As one can see, the circle sizes don’t fit double-digit numbers well.
I’ve tried to come up with a circle size that would fit both single- and double-digit numbers, but the ideal would be for the circle to "expand", perhaps inserting the footnote number inside the Tikz node. Another option could be to set the size according to number, with an if ... else ... fi
construction (cannot figure out how to do that, either). If there’s an easier solution with Metapost, I’ll gladly use it.
setupbodyfont[palatino,10pt]
usecolors[crayola]
usemodule[t-tikz]
%definefontfeature[f:sups][sups=yes]
setupnote [footnote][textcommand={tikz[overlay]fill[MagicMint] (.5ex,.8ex) circle (1.4ex);},
%textstyle=addff{f:sups},
textcolor=Scarlet]
setupnotation[footnote][way=bychapter,
numbercommand={tikz[overlay]fill[MagicMint] (.5ex,.8ex) circle (1.4ex);},
%headstyle=addff{f:sups},%headstyle={ssbf},
headcolor=Scarlet]
setupfootnotes[rulecolor=TropicalRainForest,rulethickness=.8pt]%
setupfootnotedefinition[
alternative={left,bottom} % where to set the footnote, comment it to leave it inside the margin
hang=fit, % if commented, hanging is larger
indenting={yes,small},indentnext=yes, % please, indent everything
]
starttext
chapter{One}
dorecurse{12}{footnote{}}
chapter{One}
dorecurse{12}{footnote{}}
stoptext
Just for anyone interested, a TikZ-less alternative using overlays which doesn't require manual size adjustment, sorta. Advantages are: not using TikZ, is portable across ConTeXt distributions and less prone to errors. Drawbacks are: since ConTeXt seems to "stack" elements, a small overlap occurs sometimes, but with a small enough offset it doesn't happen anyway.
%setuppapersize[A5]
setupbodyfont[palatino,10pt]
usecolors[crayola]
startuseMPgraphic{blackbird}
numeric Offset, Size;
Size := OverlayWidth;
%Without an offset circles look too small
%Change ad libitum
Offset := 0.1EmWidth;
fill fullcircle scaled (Size + Offset) withcolor "MagicMint";
stopuseMPgraphic
defineoverlay[blackbird][useMPgraphic{blackbird}]
setupnote[footnote]
[textcommand={framed[frame=off,background=blackbird]},
textcolor=Scarlet]
setupnotation[footnote]
[way=bychapter,
numbercommand={framed[frame=off,background=blackbird]},
headcolor=Scarlet]
setupfootnotes
[rulecolor=TropicalRainForest,
rulethickness=.8pt]
setupfootnotedefinition
[alternative={left,bottom},
hang=fit,
indenting={yes,small},
indentnext=yes]
starttext
startchapter[title=Uno]
dorecurse{12}{Texto footnote{Nota a pie de página} }
stopchapter
startchapter[title=Dos]
dorecurse{12}{Más texto footnote{Otra nota} }
stopchapter
stoptext
Correct answer by Jairo A. del Rio on March 2, 2021
I found an answer myself using rawcountervalue
:
setupbodyfont[palatino,10pt]
usecolors[crayola]
usemodule[t-tikz]
startsetups bola
ifnumrawcountervalue[footnote]>9
tikz[overlay]fill[MagicMint] (1.1ex,.8ex) circle (1.6ex);
else
tikz[overlay]fill[MagicMint] (.5ex,.8ex) circle (1.4ex);
fi
stopsetups
%definefontfeature[f:sups][sups=yes]
setupnote [footnote][textcommand=setups{bola},
%textstyle=addff{f:sups},
textcolor=Scarlet]
setupnotation[footnote][way=bychapter,
numbercommand=setups{bola},
%headstyle=addff{f:sups},%headstyle={ssbf},
headcolor=Scarlet]
setupfootnotes[rulecolor=TropicalRainForest,rulethickness=.8pt]%
setupfootnotedefinition[
alternative={left,bottom} % where to set the footnote, comment it to leave it inside the margin
hang=fit, % if commented, hanging is larger
indenting={yes,small},indentnext=yes, % please, indent everything
]
starttext
chapter{One}
dorecurse{12}{footnote{Footnote.}}
chapter{One}
dorecurse{12}{footnote{}}
stoptext
Answered by BlackBird on March 2, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP