# Cauchy's two-line notation in LaTeX when columns extend outside horizontal box

I need help with writing a permutation in Cauchy's two-line notation that has many columns please. Because there are so many columns, it extends outside the horizontal box. I have decided that the best thing to do is to split it over two lines.

Below is a MWE. The first produces the notation exactly how I would like it if it didn't extend outside the horizontal box. The second is an attempt to split it over two lines so it is within the horizontal box. I am more or less happy with the second one, except for how it treats the parentheses. I want the left parenthesis to take the first two lines and the right parenthesis to take the last two lines.

\documentclass{article}

\usepackage{amsmath}
\usepackage{multirow}

\begin{document}

\begin{align*}
\sigma=\left(\begin{array}{cccccccccccccc}
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{array}\right).
\end{align*}

\begin{align*}
\begin{tabular}{ccccccccc}
\multirow{2}{*}{$\sigma=($} & $1$ & $2$ & $3$ & $4$ & \ldots{} & $\frac{n}{2}-1$ & $\frac{n}{2}$ & \\
& $1$ & $\frac{n}{2}+1$ & $3$ & $\frac{n}{2}+3$ & \ldots{} & $\frac{n}{2}-1$ & $n-1$ & \\
& $\frac{n}{2}+1$ & $\frac{n}{2}+2$ & \ldots{} & $n-3$ & $n-2$ & $n-1$ & $n$ & \multirow{2}{*}{)} \\
& $\frac{n}{2}$ & $\frac{n}{2}+2$ & \ldots{} & $4$ & $n-2$ & $2$ & $n$ & \\
\end{tabular}.
\end{align*}

\end{document}


Cauchy's two-line notation is essentially just a matrix with two rows, so a solution using matrices would be fine too. Any other suggestions to make the notation take less space are welcome too.

Thank you.

Welcome! Maybe something like this?

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
\sigma=\left(\begin{array}{@{}*{20}{c@{}}}
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{array}\right).
\end{equation*}
or
\begin{equation*}
\sigma=\left(\begin{array}{@{}*{20}{c@{\,}}}
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{array}\right).
\end{equation*}

\end{document}


You can also just set the \arraycolsep to whatever value you like.

\documentclass{article}

\usepackage{amsmath}

\setcounter{MaxMatrixCols}{20}
\begin{document}

\begin{equation*}\setlength{\arraycolsep}{0.5pt}
\sigma=\begin{pmatrix}
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{pmatrix}.
\end{equation*}
\end{document}


You may want to make these changes local.

\documentclass{article}

\usepackage{amsmath}

\setcounter{MaxMatrixCols}{20}
\newenvironment{CauchyArray}[1][1pt]{\begingroup\setlength{\arraycolsep}{#1}\begin{pmatrix}}
{\end{pmatrix}\endgroup}
\begin{document}

\begin{equation*}
\sigma=\begin{CauchyArray}
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{CauchyArray}.
\end{equation*}

\begin{equation*}
\sigma=\begin{CauchyArray}[1.5pt]
1 & 2 & 3 & 4 & \ldots{} & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n  \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots{} & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n  \\
\end{CauchyArray}.
\end{equation*}

\end{document}


• Thank you, but there isn't enough horizontal spacing for my liking. Is there a way of maximizing the horizontal spacing without going outside the page limits? Mar 24, 2020 at 3:49
• @JonathanMitchell In principle, yes, but then the gaps will look different in each scheme. I added a version with a bit more space.
– user194703
Mar 24, 2020 at 3:53
• Thanks for your help. That seems to work quite well if I introduce a bit more space and change the fractions. Here's what I did. \begin{equation*} \sigma=\left(\begin{array}{@{}*{20}{c@{\,\,\,}}} 1 & 2 & 3 & 4 & \ldots{} & \frac{n-2}{2} & \frac{n}{2} & \frac{n+2}{2} & \frac{n+4}{2} & \ldots{} & n-3 & n-2 & n-1 & n \\ 1 & \frac{n+2}{2} & 3 & \frac{n+6}{2} & \ldots{} & \frac{n-2}{2} & n-1 & \frac{n}{2} & \frac{n+2}{2} & \ldots{} & 4 & n-2 & 2 & n \\ \end{array}\right). \end{equation*} Mar 24, 2020 at 4:01
• @JonathanMitchell You can also play with \arraycolsep. Maybe this is the cleaner option.
– user194703
Mar 24, 2020 at 4:13
• That's a bit better. It gives me a bit more flexibility. Thanks. Mar 24, 2020 at 4:23

Your array contains 14 columns and hence 13 intercolumn spaces. To make your array (or pmatrix) environment fit inside the text block, you have two main, not mutually exclusive, options:

• reduce the value of the \arraycolsep parameter (default value: 5pt), which governs the amount of intercolumn whitespace. (This is the approach taken in the earlier answer of @Schrödinger'scat.)

• reduce the value of the \medmuskip parameter (default value: 4mu), which governs the amount of whitespace inserted around binary operators such as + and -.

Nine of the 14 columns in the array contain binary-op + and - symbols. As the following screenshot demonstrates, reducing the value of \medmuskip from 4mu to 1mu allows raising the value of \arraycolsep from 1.25pt back to 2.5pt. In consequence, the intercolumn space now exceeds the space around the + and - symbols. In my opinion, this makes for a more visually balanced and hence also more readable result.

\documentclass{article}
\usepackage{amsmath}
\setcounter{MaxMatrixCols}{14} % default: 10
\begin{document}

$\setlength\arraycolsep{1.25pt} % default: 5pt \sigma=\begin{pmatrix} 1 & 2 & 3 & 4 & \ldots & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \ldots & n-3 & n-2 & n-1 & n \\ 1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \ldots & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \ldots & 4 & n-2 & 2 & n \\ \end{pmatrix}.$

$\setlength\arraycolsep{2.5pt} % default: 5pt \setlength\medmuskip{1mu} % default: 4mu \sigma=\begin{pmatrix} 1 & 2 & 3 & 4 & \dots & \frac{n}{2}-1 & \frac{n}{2} & \frac{n}{2}+1 & \frac{n}{2}+2 & \dots & n-3 & n-2 & n-1 & n \\ 1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \dots & \frac{n}{2}-1 & n-1 & \frac{n}{2} & \frac{n}{2}+2 & \dots & 4 & n-2 & 2 & n \\ \end{pmatrix}.$
\end{document}


Here's how you can split the object across two lines:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation*}
\sigma=\biggl(
\begin{aligned}[t]
& \begin{array}{@{}*{7}{c}@{}}
1 & 2 & 3 & 4 & \dots & \frac{n}{2}-1 & \frac{n}{2} \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \dots & \frac{n}{2}-1 & n-1
\end{array}
\\
& \begin{array}{@{}*{7}{c}@{}}
\frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n \\
\frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n
\end{array}\biggr).
\end{aligned}
\end{equation*}

\end{document}


Alternative:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{multline*}
\sigma=\biggl(
\begin{array}{@{}*{7}{c}@{}}
1 & 2 & 3 & 4 & \dots & \frac{n}{2}-1 & \frac{n}{2} \\
1 & \frac{n}{2}+1 & 3 & \frac{n}{2}+3 & \dots & \frac{n}{2}-1 & n-1
\end{array}
\\
\begin{array}{@{}*{7}{c}@{}}
\frac{n}{2}+1 & \frac{n}{2}+2 & \ldots{} & n-3 & n-2 & n-1 & n \\
\frac{n}{2} & \frac{n}{2}+2 & \ldots{} & 4 & n-2 & 2 & n
\end{array}\biggr).
\end{multline*}

\end{document}