I'm trying to create a 3 column book layout. So far the only way I've figured out to get 3 columns is to use the venerable multicol package, which works nicely. Using the answer from this question Automatically add \begin{multicols}{N} to chapters I'm attempting to use etoolbox to automatically insert the \begin \end multicols whenever I type \chapter; however, this breaks when styling chapters using titlesec.
\documentclass{book}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{titlesec} % Customize chapters and sections
\usepackage{kantlipsum}
% Automatically wrap \chapter with \begin and \end multicols
\newif\iffirst
\makeatletter
\appto{\mainmatter}
{\firsttrue
\preto{\chapter}{\iffirst\firstfalse\else\end{multicols*}\fi}
\preto{\enddocument}{\end{multicols*}}
\apptocmd{\@makechapterhead}{\begin{multicols*}{3}}{}{}
\apptocmd{\@makeschapterhead}{\begin{multicols*}{3}}{}{}
}
\makeatother
% Format chapter heading
\titleformat
{\chapter} % command
[display] % shape
{\LARGE} % format
{} % label
{-1.75cm} % horizontal separation between label and title body
{Chapter \thechapter. \enspace \vspace{0cm}} % before-code
[] % after-code
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{A chapter}
\kant
\chapter{A chapter}
\kant
\chapter{A chapter}
\kant
\end{document}
Latex complains about a ! Argument of \begin has an extra }. What's the best way to make this work?
~ > lualatex example.tex...! You can't use macro parameter character # in horizontal mode.<argument> \numberline {1}########3Ubuntu 16.04
– Zendel Sep 10 '18 at 14:20