I have a lot of chapters and sections inside chapters tex file. I want to make a separate folder for chapter and there put separate sections tex files. How I should do this? I am using report for now, so I am just \include
all chapters files in maintex. I am thinking of changing everything to book, but I don't know will it look the same? Or maybe I could stay with report?
[Tex/LaTex] how to separate chapters and section
chapterssectioning
Related Solutions
As switching between twocolumn
and onecolumn
causes a page break, one may use the multicol
package and its multicols
environment instead. (The environment's optional argument is used for introductory one-column material.) In the following example, I use the twocolumn
class option to achieve smaller margins, then temporarily switch two \onecolumn
at the start of the document. Page breaks before chapters are removed by disabling \clearpage
inside a group.
Note: The vertical space before chapter 1 (typeset with multicols
) is actually larger than the space before chapter 3 (typeset with \twocolumn
). The larger space is caused by LaTeX bug 3126 (\twocolumn
interfering with \topskip
); for consistent spacing, use multicols
environments for every chapter of your document. EDIT: Even better, use Frank Mittelbachs answer to Is it possible to define a `multicols{2}` preamble switch that works for \chapter?
\documentclass[twocolumn]{book}
\usepackage{multicol}
\setlength{\columnsep}{20pt}
\newcommand*{\sometext}{Hello, here is some text without a meaning. This
text should show, how a printed text will look like at this place.
If you read this text, you will get no information.}
\begin{document}
\onecolumn
\begingroup
\let\clearpage\relax
\begin{multicols}{2}[%
\chapter{First (and some text to fill the line)}%
]
\sometext
\end{multicols}
\begin{multicols}{2}[%
\chapter{Second (and some text to fill the line)}%
]
\sometext
\end{multicols}
\endgroup
\twocolumn
\chapter{Third (and some text to fill the line)}
\sometext
\chapter{Fourth (and some text to fill the line)}
\sometext
\end{document}
Here' a possible solution using the titlesec package to add the color to the chapter headings; the color for the part headings (and their ToC entries) was added through a redefinition of the internal macros \part
, \@part
and \@spart
; the color for the chapter entries in the ToC was achieved by redefining \@chapter
. The color schema was implemente through a simple \ifcase
:
\documentclass[11pt,letterpaper]{book}
\usepackage{amsfonts,amsthm,amssymb}
\usepackage[tbtags]{amsmath}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage{chngcntr}
\newcommand\MyColor{black}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[LE,RO]{\slshape\color{\MyColor}\thepage}
\fancyhead[RE]{\slshape\color{\MyColor}\leftmark}
\fancyhead[LO]{\slshape\color{\MyColor}\rightmark}
\counterwithin{chapter}{part}
\renewcommand{\thepart}{\Alph{part}}
\renewcommand{\thechapter}{\Roman{chapter}}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\color{\MyColor}}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\makeatletter
\renewcommand\part{%
\if@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{plain}%
\renewcommand\MyColor{%
\ifcase\value{part} \or blue\or red\or olive\or magenta\else yellow\fi}
\if@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}{\color{\MyColor}\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{part}{\color{\MyColor}#1}%
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >-2\relax
\huge\bfseries\color{\MyColor} \partname\nobreakspace\thepart
\par
\vskip 20\p@
\fi
\Huge \bfseries #2\par}%
\@endpart}
\def\@spart#1{%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #1\par}%
\@endpart}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{\color{\MyColor}\protect\numberline{\thechapter}#1}%
\else
\addcontentsline{toc}{chapter}{\color{\MyColor}#1}%
\fi
\else
\addcontentsline{toc}{chapter}{\color{\MyColor}#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\makeatother
\begin{document}
\tableofcontents
\part{Test Part One}
\chapter{Chapter A-One}
\lipsum[1]
\section{Test section A-One One}
\lipsum[1-10]
\chapter{Chapter A-Two}
\lipsum[1]
\section{Test section A-Two One}
\lipsum[1-10]
\part{Test Part Two}
\chapter{Chapter B-One}
\lipsum[1-7]
\chapter{Chapter B-Two}
\lipsum[1-7]
\part{Test Part Three}
\chapter{Chapter C-One}
\lipsum[1-7]
\chapter{Chapter C-Two}
\lipsum[1-7]
\end{document}
Here are some pages of the final document:
And an image of the ToC:
Just as a personal comment, this coloring schema has to be handled very carefully (selecting the appropriate colors is crucial) in order not to become distracting and to avoid achieving an unpleasant layout.
Best Answer
book
andreport
are the same in this respect, just continue to use\include
for chapters and then\input
the files with sections.