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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
% arara: pdflatex: {shell: yes, files: [latexindent]}
\appendix
\section{Required Perl modules}\label{sec:requiredmodules}
If you intend to use \texttt{latexindent.pl} and \emph{not} one of the
supplied standalone executable files, then you will need a few standard Perl modules --
if you can run the minimum code in \cref{lst:helloworld} (\texttt{perl helloworld.pl}) then you will be able to run
\texttt{latexindent.pl}, otherwise you may need to install the missing modules -- see
\cref{sec:module-installer,sec:manual-module-instal}.
\begin{cmhlistings}[style=tcblatex,language=Perl]{\texttt{helloworld.pl}}{lst:helloworld}
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use PerlIO::encoding;
use Unicode::GCString;
use open ':std', ':encoding(UTF-8)';
use Text::Wrap;
use Text::Tabs;
use FindBin;
use YAML::Tiny;
use File::Copy;
use File::Basename;
use File::HomeDir;
use Getopt::Long;
use Data::Dumper;
use List::Util qw(max);
use Log::Log4perl qw(get_logger :levels);
print "hello world";
exit;
\end{cmhlistings}
\subsection{Module installer script}\label{sec:module-installer}
\announce{2018-01-13}{perl module helper script} \texttt{latexindent.pl} ships with a helper script that will
install any missing \texttt{perl} modules on your system; if you run
\begin{commandshell}
perl latexindent-module-installer.pl
\end{commandshell}
or
\begin{dosprompt}
perl latexindent-module-installer.pl
\end{dosprompt}
then, once you have answered \texttt{Y}, the appropriate modules will be
installed onto your distribution.
\subsection{Manually installed modules}\label{sec:manual-module-instal}
Manually installing the modules given in \cref{lst:helloworld} will vary depending on
your operating system and \texttt{Perl} distribution.
\subsubsection{Linux}
Linux users may be interested in exploring Perlbrew \cite{perlbrew}; an example
installation would be:
\begin{commandshell}
sudo apt-get install perlbrew
perlbrew init
perlbrew install perl-5.28.1
perlbrew switch perl-5.28.1
sudo apt-get install curl
curl -L http://cpanmin.us | perl - App::cpanminus
cpanm YAML::Tiny
cpanm File::HomeDir
cpanm Unicode::GCString
cpanm Log::Log4perl
cpanm Log::Dispatch
\end{commandshell}
For other distributions, the Ubuntu/Debian approach may work by visiting the software
center, or else by running, for example,
\begin{commandshell}
sudo perl -MCPAN -e'install "File::HomeDir"'
\end{commandshell}
If you are using Alpine, some \texttt{Perl} modules are not build-compatible
with Alpine, but replacements are available through \texttt{apk}. For example,
you might use the commands given in \cref{lst:alpine-install}; thanks to
\cite{jun-sheaf} for providing these details.
\begin{cmhlistings}[style=tcblatex,language=Bash]{\texttt{alpine-install.sh}}{lst:alpine-install}
# Installing perl
apk --no-cache add miniperl perl-utils
# Installing incompatible latexindent perl dependencies via apk
apk --no-cache add \
perl-log-log4perl \
perl-log-dispatch \
perl-namespace-autoclean \
perl-specio \
perl-unicode-linebreak
# Installing remaining latexindent perl dependencies via cpan
apk --no-cache add curl wget make
ls /usr/share/texmf-dist/scripts/latexindent
cd /usr/local/bin && \
curl -L https://cpanmin.us/ -o cpanm && \
chmod +x cpanm
cpanm -n App::cpanminus
cpanm -n File::HomeDir
cpanm -n Params::ValidationCompiler
cpanm -n YAML::Tiny
cpanm -n Unicode::GCString
\end{cmhlistings}
Users of NixOS might like to see \href{https://github.com/cmhughes/latexindent.pl/issues/222}{https://github.com/cmhughes/latexindent.pl/issues/222} for tips.
\subsubsection{Mac}
Users of the Macintosh operating system might like to explore the following commands, for
example:
\begin{commandshell}
brew install perl
brew install cpanm
cpanm YAML::Tiny
cpanm File::HomeDir
cpanm Unicode::GCString
cpanm Log::Log4perl
cpanm Log::Dispatch
\end{commandshell}
\subsubsection{Windows}
Strawberry Perl users on Windows might use \texttt{CPAN client}. All of the modules are
readily available on CPAN \cite{cpan}.
\texttt{indent.log} will contain details of the location
of the Perl modules on your system. \texttt{latexindent.exe} is a standalone executable
for Windows (and therefore does not require a Perl distribution) and caches copies of the
Perl modules onto your system; if you wish to see where they are cached, use the
\texttt{trace} option, e.g
\begin{dosprompt}
latexindent.exe -t myfile.tex
\end{dosprompt}
\section{Updating the path variable}\label{sec:updating-path}
\texttt{latexindent.pl} has a few scripts (available at \cite{latexindent-home}) that can
update the \texttt{path} variables. Thank you to \cite{jasjuang} for this
feature. If you're on a Linux or Mac machine, then you'll want \texttt{CMakeLists.txt}
from \cite{latexindent-home}.
\subsection{Add to path for Linux}
To add \texttt{latexindent.pl} to the path for Linux, follow these steps:
\begin{enumerate}
\item download \texttt{latexindent.pl} and its associated modules, \texttt{defaultSettings.yaml}, to
your chosen directory from \cite{latexindent-home} ;
\item within your directory, create a directory called \texttt{path-helper-files} and download
\texttt{CMakeLists.txt} and \lstinline!cmake_uninstall.cmake.in! from
\cite{latexindent-home}/path-helper-files to this directory;
\item run
\begin{commandshell}
ls /usr/local/bin
\end{commandshell}
to see what is \emph{currently} in there;
\item run the following commands
\begin{commandshell}
sudo apt-get install cmake
sudo apt-get update && sudo apt-get install build-essential
mkdir build && cd build
cmake ../path-helper-files
sudo make install
\end{commandshell}
\item run
\begin{commandshell}
ls /usr/local/bin
\end{commandshell}
again to check that \texttt{latexindent.pl}, its modules and \texttt{defaultSettings.yaml} have
been added.
\end{enumerate}
To \emph{remove} the files, run
\begin{commandshell}
sudo make uninstall
\end{commandshell}
\subsection{Add to path for Windows}
To add \texttt{latexindent.exe} to the path for Windows, follow these steps:
\begin{enumerate}
\item download \texttt{latexindent.exe}, \texttt{defaultSettings.yaml}, \texttt{add-to-path.bat} from
\cite{latexindent-home} to your chosen directory;
\item open a command prompt and run the following command to see what is \emph{currently}
in your \lstinline!%path%! variable;
\begin{dosprompt}
echo %path%
\end{dosprompt}
\item right click on \texttt{add-to-path.bat} and \emph{Run as administrator};
\item log out, and log back in;
\item open a command prompt and run
\begin{dosprompt}
echo %path%
\end{dosprompt}
to check that the appropriate directory has been added to your \lstinline!%path%!.
\end{enumerate}
To \emph{remove} the directory from your \lstinline!%path%!, run
\texttt{remove-from-path.bat} as administrator.
\section{logFilePreferences}\label{app:logfile-demo}
\Vref{lst:logFilePreferences} describes the options for customising the information given
to the log file, and we provide a few demonstrations here. Let's say that we start with
the code given in \cref{lst:simple}, and the settings specified in
\cref{lst:logfile-prefs1-yaml}.
\begin{minipage}{.35\linewidth}
\cmhlistingsfromfile{demonstrations/simple.tex}{\texttt{simple.tex}}{lst:simple}
\end{minipage}
\hfill
\begin{minipage}{.6\linewidth}
\cmhlistingsfromfile{demonstrations/logfile-prefs1.yaml}[yaml-TCB]{\texttt{logfile-prefs1.yaml}}{lst:logfile-prefs1-yaml}
\end{minipage}
If we run the following command (noting that \texttt{-t} is active)
\begin{commandshell}
latexindent.pl -t -l=logfile-prefs1.yaml simple.tex
\end{commandshell}
then on inspection of \texttt{indent.log} we will find the snippet given in
\cref{lst:indentlog}.
\begin{cmhlistings}[style=tcblatex,morekeywords={TRACE}]{\texttt{indent.log}}{lst:indentlog}
+++++
TRACE: environment found: myenv
No ancestors found for myenv
Storing settings for myenvenvironments
indentRulesGlobal specified (0) for environments, ...
Using defaultIndent for myenv
Putting linebreak after replacementText for myenv
looking for COMMANDS and key = {value}
TRACE: Searching for commands with optional and/or mandatory arguments AND key = {value}
looking for SPECIAL begin/end
TRACE: Searching myenv for special begin/end (see specialBeginEnd)
TRACE: Searching myenv for optional and mandatory arguments
... no arguments found
-----
\end{cmhlistings}
Notice that the information given about \texttt{myenv} is `framed' using
\texttt{+++++} and \lstinline!-----! respectively.
\section{Differences from Version 2.2 to 3.0}\label{app:differences}
There are a few (small) changes to the interface when comparing Version 2.2 to Version
3.0. Explicitly, in previous versions you might have run, for example,
\begin{commandshell}
latexindent.pl -o myfile.tex outputfile.tex
\end{commandshell}
whereas in Version 3.0 you would run any of the following, for example,
\begin{commandshell}
latexindent.pl -o=outputfile.tex myfile.tex
latexindent.pl -o outputfile.tex myfile.tex
latexindent.pl myfile.tex -o outputfile.tex
latexindent.pl myfile.tex -o=outputfile.tex
latexindent.pl myfile.tex -outputfile=outputfile.tex
latexindent.pl myfile.tex -outputfile outputfile.tex
\end{commandshell}
noting that the \emph{output} file is given \emph{next to} the
\texttt{-o} switch.
The fields given in \cref{lst:obsoleteYaml} are \emph{obsolete} from Version 3.0
onwards. \cmhlistingsfromfile{demonstrations/obsolete.yaml}[yaml-obsolete]{Obsolete YAML fields from Version 3.0}{lst:obsoleteYaml}
There is a slight difference when specifying indentation after headings; specifically, we
now write \texttt{indentAfterThisHeading} instead of \texttt{indent}. See
\cref{lst:indentAfterThisHeadingOld,lst:indentAfterThisHeadingNew}
\begin{minipage}{.45\textwidth}
\cmhlistingsfromfile{demonstrations/indentAfterThisHeadingOld.yaml}[yaml-TCB]{\texttt{indentAfterThisHeading} in Version 2.2}{lst:indentAfterThisHeadingOld}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
\cmhlistingsfromfile{demonstrations/indentAfterThisHeadingNew.yaml}[yaml-TCB]{\texttt{indentAfterThisHeading} in Version 3.0}{lst:indentAfterThisHeadingNew}
\end{minipage}%
To specify \texttt{noAdditionalIndent} for display-math environments in Version 2.2, you
would write YAML as in \cref{lst:noAdditionalIndentOld}; as of Version 3.0, you would write YAML
as in \cref{lst:indentAfterThisHeadingNew1} or, if you're using \texttt{-m} switch,
\cref{lst:indentAfterThisHeadingNew2}.
\begin{minipage}{.45\textwidth}
\cmhlistingsfromfile{demonstrations/noAddtionalIndentOld.yaml}[yaml-TCB]{\texttt{noAdditionalIndent} in Version 2.2}{lst:noAdditionalIndentOld}
\end{minipage}%
\hfill
\begin{minipage}{.45\textwidth}
\cmhlistingsfromfile{demonstrations/noAddtionalIndentNew.yaml}[yaml-TCB]{\texttt{noAdditionalIndent} for \texttt{displayMath} in Version 3.0}{lst:indentAfterThisHeadingNew1}
\cmhlistingsfromfile{demonstrations/noAddtionalIndentNew1.yaml}[yaml-TCB]{\texttt{noAdditionalIndent} for \texttt{displayMath} in Version 3.0}{lst:indentAfterThisHeadingNew2}
\end{minipage}%
\mbox{}\hfill \begin{minipage}{.25\textwidth}
\hrule
\hfill\itshape End\\\mbox{}\hfill\mbox{}\rlap{\hfill\includegraphics{logo}}
\end{minipage}
|