summaryrefslogtreecommitdiff
path: root/support/latexindent/documentation/subsec-partnering-poly-switches.tex
blob: 4c0b7a8f051f5652d56348b7af5db390bb4ca52c (plain)
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
% arara: pdflatex: {shell: yes, files: [latexindent]}
\subsection{Partnering BodyStartsOnOwnLine with argument-based poly-switches}
	Some poly-switches need to be partnered together; in particular, when line breaks
	involving the \emph{first} argument of a code block need to be accounted for
	using both \texttt{BodyStartsOnOwnLine} (or its equivalent, see \vref{tab:poly-switch-mapping}) and \texttt{LCuBStartsOnOwnLine} for mandatory arguments, and
	\texttt{LSqBStartsOnOwnLine} for optional arguments.
	\index{poly-switches!conflicting partnering}

	Let's begin with the code in \cref{lst:mycommand1} and the YAML settings in
	\cref{lst:mycom-mlb1}; with reference to \vref{tab:poly-switch-mapping}, the key
	\texttt{CommandNameFinishesWithLineBreak} is an alias for \texttt{BodyStartsOnOwnLine}.

	\cmhlistingsfromfile{demonstrations/mycommand1.tex}{\texttt{mycommand1.tex}}{lst:mycommand1}

	Upon running the command
	\index{switches!-l demonstration}
	\index{switches!-m demonstration}
	\begin{commandshell}
latexindent.pl -m -l=mycom-mlb1.yaml mycommand1.tex
\end{commandshell}
	we obtain \cref{lst:mycommand1-mlb1}; note that the \emph{second} mandatory argument
	beginning brace \lstinline!{! has had its leading line break removed, but that
	the \emph{first} brace has not.

	\begin{cmhtcbraster}[
			raster force size=false,
			raster column 1/.style={add to width=-1cm},
		]
		\cmhlistingsfromfile{demonstrations/mycommand1-mlb1.tex}{\texttt{mycommand1.tex} using \cref{lst:mycom-mlb1}}{lst:mycommand1-mlb1}
		\cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb1.yaml}[MLB-TCB,width=.6\textwidth]{\texttt{mycom-mlb1.yaml}}{lst:mycom-mlb1}
	\end{cmhtcbraster}

	Now let's change the YAML file so that it is as in \cref{lst:mycom-mlb2}; upon running
	the analogous command to that given above, we obtain \cref{lst:mycommand1-mlb2}; both
	beginning braces \lstinline!{! have had their leading line breaks removed.

	\begin{cmhtcbraster}[
			raster force size=false,
			raster column 1/.style={add to width=-1cm},
		]
		\cmhlistingsfromfile{demonstrations/mycommand1-mlb2.tex}{\texttt{mycommand1.tex} using \cref{lst:mycom-mlb2}}{lst:mycommand1-mlb2}
		\cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb2.yaml}[MLB-TCB,width=.6\textwidth]{\texttt{mycom-mlb2.yaml}}{lst:mycom-mlb2}
	\end{cmhtcbraster}

	Now let's change the YAML file so that it is as in \cref{lst:mycom-mlb3}; upon running
	the analogous command to that given above, we obtain \cref{lst:mycommand1-mlb3}.

	\begin{cmhtcbraster}[
			raster force size=false,
			raster column 1/.style={add to width=-1cm},
		]
		\cmhlistingsfromfile{demonstrations/mycommand1-mlb3.tex}{\texttt{mycommand1.tex} using \cref{lst:mycom-mlb3}}{lst:mycommand1-mlb3}
		\cmhlistingsfromfile[style=yaml-LST]*{demonstrations/mycom-mlb3.yaml}[MLB-TCB,width=.6\textwidth]{\texttt{mycom-mlb3.yaml}}{lst:mycom-mlb3}
	\end{cmhtcbraster}