Skip to content

Commit

Permalink
Use proper latex counters for boxes
Browse files Browse the repository at this point in the history
Specifically find-out-more and windows-wit. This makes it now possible
to do "numerical" references, and removes the need for the "on the topic
of..." suffixes in the text somewhat.
  • Loading branch information
mih committed Sep 10, 2021
1 parent 520059f commit bcf5f19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
15 changes: 12 additions & 3 deletions dataladhandbook_support/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ def _get_counted_boxstart(label, node):
if flt else ', float'
return \
"\\begin{{{label}}}" \
"[before title={{\\thetcbcounter\\ }}{float_args}]" \
"[{ref}before title={{\\thetcbcounter\\ }}{float_args}]" \
"{{{title}}}\n".format(
ref='label={{{r}}}, '.format(r=node.attributes['ids'][0])
if len(node.attributes.get('ids', []))
else '',
label=label,
title=title,
float_args=float_args,
Expand Down Expand Up @@ -237,7 +240,10 @@ def depart_findoutmoreref_html(self, node):


def visit_findoutmoreref_latex(self, node):
self.body.append('{\\findoutmoreiconinline}\sphinxcrossref{Find-out-more }')
# \textit to immitate the href style
self.body.append(
'\\textit{{Find-out-more}}~{{\\findoutmoreiconinline}}\\textit{{\\ref{{{r}}}}} '.format(
r=node.children[0].attributes['refid']))


def depart_findoutmoreref_latex(self, node):
Expand All @@ -258,7 +264,10 @@ def depart_windowswitref_html(self, node):


def visit_windowswitref_latex(self, node):
self.body.append('{\\windowswiticoninline}\sphinxcrossref{Windows-wit }')
# \textit to immitate the href style
self.body.append(
'\\textit{{Windows-wit}}~{{\\windowswiticoninline}}\\textit{{\\ref{{{r}}}}} '.format(
r=node.children[0].attributes['refid']))


def depart_windowswitref_latex(self, node):
Expand Down
15 changes: 11 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,35 +390,42 @@
\end{scope}}}
}
\newcounter{HandbookWIN}[chapter]
\renewcommand\theHandbookWIN{W\arabic{chapter}.\arabic{HandbookWIN}}
\newtcolorbox[%
auto counter,
use counter*=HandbookWIN,
number within=chapter,
list inside=windowswits]{windowswit}[2][]{%
enhanced, ribbon win, title={#2},
coltitle=dataladgray,
colbacktitle=windowsgreen,
colframe=windowsgreen!70!black, #1
}
\newcounter{HandbookGIT}[chapter]
\renewcommand\theHandbookGIT{G\arabic{chapter}.\arabic{HandbookGIT}}
\newtcolorbox[%
auto counter,
use counter*=HandbookGIT,
number within=chapter,
list inside=gitusernotes]{gitusernote}[2][]{%
enhanced, ribbon git, title={#2},
coltitle=dataladgray,
colbacktitle=dataladblue,
colframe=dataladblue!70!black, #1
}
\newcounter{HandbookFOM}[chapter]
\renewcommand\theHandbookFOM{M\arabic{chapter}.\arabic{HandbookFOM}}
\newtcolorbox[
auto counter,
use counter*=HandbookFOM,
number within=chapter,
list inside=findoutmores]{findoutmore}[2][]{%
enhanced, ribbon more, title={#2},
coltitle=dataladgray,
colbacktitle=dataladyellow,
colframe=dataladyellow!70!black, #1
}
% unnumbered, they are short and placed at the exact position
% must change we there are in-text references
\newtcolorbox[
auto counter,
number within=chapter,
list inside=importantnotes]{importantnote}[2][]{%
enhanced, ribbon important, title={#2},
Expand Down

0 comments on commit bcf5f19

Please sign in to comment.