-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyles_data.tex
64 lines (59 loc) · 2.91 KB
/
styles_data.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
\makeatletter
\newcommand{\replaceunderscores}[1]{\expandafter\replace@underscores#1_\relax}
\def\replace@underscores#1_#2\relax{%
\ifx \relax #2\relax
#1%
\else
#1%
\textunderscore
\replace@underscores#2\relax
\fi
}
\ExplSyntaxOn
% Generic \Smart@Item macro:
% use \NEWRAW*{WHATEVER_THIS_IS} where hyperlinks are not needed (TOC, sections...)
% and \RAW{WHATEVER_THIS_IS} for a full hyperlink-enabled version in regular text and tikz figures
% #1 boolean: use hyperlink
% #2 string: uppercase type of the item
% #3 string: id of the item
% #4 string: hyperref prefix
%
% NewExpandableDocumentCommand is used instead of NewDocumentCommand because
% this ensures the table of contents is correct if the macros are used in
% section headers. The xparse manual warns that
%
% There are very rare occasion when it may be useful to create functions
% using a fully-expandable argument grabber. [...] This facility should
% only be used when absolutely necessary; if you do not understand when
% this might be, do not use these functions!
%
% Nevertheless, NewExpandableDocumentCommand seems to work well. However,
% the last argument has to be m, r, R, l, or u, and not O.
\NewExpandableDocumentCommand{\Smart@Item}{m m m m}{%
\IfBooleanTF{#1}{%
\texorpdfstring{\lstinline[style=#2style]!#3!}{\replaceunderscores{#3}}%
}{%
% Replace spaces (e.g. in "QC ABC DEF") with underscores in order to
% create a hyperref. The result of xstring macros (StrSubstitute) is not
% expandable, and thus the result has to be stored, in MyHyper.
% see section 3.2 of xstring manual.
\StrSubstitute{#3}{\space}{_}[\MyHyper]
\texorpdfstring{\hyperref[#4:\text_lowercase:n{\MyHyper}]{\lstinline[style=#2style]!#3!}}{\replaceunderscores{#3}}%
}%
}
\ExplSyntaxOff
% Raw FITS file: \RAW{LM_SCI_RAW}
\NewDocumentCommand{\RAW} {s m}{\Smart@Item{#1}{RAW} {#2}{dataitem}}
\NewDocumentCommand{\PAR} {s m}{\Smart@Item{#1}{PAR} {#2}{dataitem}}
\NewDocumentCommand{\DRL} {s m}{\Smart@Item{#1}{DRL} {#2}{drl}}
\NewExpandableDocumentCommand{\REC} {s m}{\Smart@Item{#1}{REC} {#2}{rec}}
\NewDocumentCommand{\QC} {s m}{\Smart@Item{#1}{QC} {#2}{qc}}
\NewDocumentCommand{\PROD} {s m}{\Smart@Item{#1}{PROD} {#2}{dataitem}}
\NewDocumentCommand{\EXTCALIB} {s m}{\Smart@Item{#1}{EXTCALIB} {#2}{dataitem}}
\NewDocumentCommand{\STATCALIB}{s m}{\Smart@Item{#1}{STATCALIB}{#2}{dataitem}}
\NewDocumentCommand{\FITS} {s m}{\Smart@Item{#1}{FITS} {#2}{fits}}
% Templates: they do not have the starred version, no hyperrefs are created
\NewDocumentCommand{\TPL} {m}{\Smart@Item{\BooleanTrue}{TPL}{#1}{}}
% Requirements: this only points to Polarion, no internal hyperrefs are created
\NewDocumentCommand{\REQ} {m}{\href{https://polarion.astron.nl/polarion/\#/project/METIS/workitem?id=#1}{\textcolor{brown}{#1}}}
\makeatother