-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutilities.tex
More file actions
84 lines (73 loc) · 2.36 KB
/
utilities.tex
File metadata and controls
84 lines (73 loc) · 2.36 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
\NewDocumentCommand{\URL}{m}{\href{#1}{\texttt{#1}}}
% package siunitx -- custom units
\NewDocumentCommand{\errorMessage}{+m}{\colorbox{red}{#1}}
\NewDocumentCommand{\todoMessage}{+m}{\colorbox{orange}{ToDo: #1}}
% Protected input -- \input entire file or typeset a warning message saying that it does not exist
\NewDocumentCommand{\protectedInput}{m}{%
\IfFileExists{#1}{%
\input{#1}%
}{%
\errorMessage{Missing file \texttt{#1}!}\\
}%
}
% Try input -- \input entire file if it exists
\NewDocumentCommand{\tryInput}{m}{%
\IfFileExists{#1}{%
\input{#1}%
}{}%
}
\NewDocumentCommand{\cutHere}{}{%
\noindent%
\raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}%
\unskip{\tiny\dotfill}
}
\NewDocumentCommand{\insertPicture}{O{} m}{%
\begin{center}
\IfFileExists{\activeDirectory/#2}{%
\includegraphics[#1]{\activeDirectory/#2}%
}{%
\includegraphics[#1]{example-image}%
}%
\end{center}
}
% \exampleIO[verbatim input][verbatim output]
% Input and output for KSP
% - verbatim input
% ₋ verbatim output
% Uses ExplSyntax from LaTeX3
\ExplSyntaxOn
\char_set_catcode_other:n{`\^^M}
\NewDocumentCommand{\exampleIO}{+v +v}{
\tl_set:Nn \l_tmpa_tl {#1}
\tl_set:Nn \l_tmpb_tl {#2}
\tl_replace_all:Nnn \l_tmpa_tl {^^M} {\par}
\tl_replace_all:Nnn \l_tmpb_tl {^^M} {\par}
\begin{minipage}[t]{0.48\linewidth}
\begin{center}vstup\end{center}
\vspace{-15pt} % one nasty hack here
\fbox{
\begin{minipage}[t]{\linewidth}
\mbox{}\\[-1.5\baselineskip] % another nasty hack here
\ttfamily
\l_tmpa_tl
\end{minipage}
}
\end{minipage}
\begin{minipage}[t]{0.0393\linewidth}
\mbox{}
\end{minipage}
\begin{minipage}[t]{0.48\linewidth}
\begin{center}výstup\end{center}
\vspace{-15pt} % guess what here
\fbox{
\begin{minipage}[t]{0.975\linewidth}
\mbox{}\\[-1.5\baselineskip] % and one nasty hack here
\ttfamily
\l_tmpb_tl
\end{minipage}
}
\end{minipage}
\\[1ex]
}
\char_set_catcode_end_line:n{`\^^M}
\ExplSyntaxOff