-
Notifications
You must be signed in to change notification settings - Fork 0
/
commons.sty
67 lines (57 loc) · 1.49 KB
/
commons.sty
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
%input
% - first part of command name
% - second part fo command name
% - number of inputs
% e.g., \generateCommand{Name}{abc}{1}{**#1**} generates \Nameabc[1]{**#1**}
\NewDocumentCommand{\generateCommand}{m m m}{%
\expandafter\newcommand\csname #1#2\endcsname[#3]%
}
\NewDocumentCommand{\generateDef}{m m}{%
\expandafter\def\csname #1 \endcsname{#2}%
}
\NewDocumentCommand{\generateToken}{m}{%
\csname #1 \endcsname%
}
%input
% - nameof the macro which will reference the file
% - filename of file
%
% example:
% \declareAuxFile{tempFile}{test.aux}
% \begin{document}
% \openAuxFile{tempFile}
% \writeLine{tempFile}{hello world}
% \closeAuxFile{tempFile}
% \end{document}
\NewDocumentCommand{\declareAuxFile}{m m}{%
\newwrite\generateToken{#1}%
\generateDef{#1@filename}{#2}%
}
% - macrov referencing the file you want to open
\NewDocumentCommand{\openAuxFile}{m}{%
\immediate\openout\generateToken{#1}=\generateToken{#1@filename}%
}
\NewDocumentCommand{\closeAuxFile}{m}{%
\immediate\closeout\generateToken{#1}%
}
% write something in the file
% - macro referecing the file you want to write ionto
\NewDocumentCommand{\writeLine}{m m}{%
\immediate\write\generateToken{#1}{#2}%
}
\NewDocumentCommand{\insertImage}{m m}{%
\begin{figure}[H]%
\centering%
\includegraphics[width=#2\textwidth]{#1}%
\label{#1}%
\end{figure}%
}
\NewDocumentCommand{\eg}{}{%
e.g.,%
}
\NewDocumentCommand{\ie}{}{%
i.e.,%
}
\NewDocumentCommand{\quotes}{m}{%
``#1''%
}