I need page breaks before each \section{...} of my document. According to this thread: Start new page with each section I am supposed to add following command:
\newcommand{\sectionbreak}{\clearpage} % page break before section
There is a problem using toc with hyperref though. Hyperlinks from toc to each section are set one page prior their actual page position. In the following example:
- If in
tocI click on hyperlink of Section 1 (which is on page 2), I will stay on page 1. - If in
tocI click on hyperlink of Section 2 (which is on page 3), I will be carried to page 2.
Here is a ready to test code:
\documentclass[12pt,a4paper]{scrartcl} % A4 paper and 12pt font size
\usepackage{hyperref} % Hyperlinks
\usepackage{titlesec} % customizing sections
\newcommand{\sectionbreak}{\clearpage} % page break before section
\begin{document}
\tableofcontents
\section{Section 1}
Text
\subsection{Subsection 1.1}
Text
\subsection{Subsection 1.2}
Text
\section{Section 2}
Text
\subsection{Subsection 2.1}
Text
\subsection{Subsection 2.2}
Text
Text
\end{document}
I need either a fix for the wrong linkage in toc or some other method of inserting page breaks before sections, which is compatible with toc hyperlinks.
\newcommand{\sectionbreak}{\clearpage\phantomsection}? – Mike Renfro Dec 23 '14 at 02:11titlesecandhyperref. You need to loadhyperrefaftertitlesec(see Which packages should be loaded afterhyperrefinstead of before?). Also KOMA-script suggests avoidtitlesecto modify the sectional units. – Werner Dec 23 '14 at 02:19hyperrefandtitlesec; hyperlinks started working as expected. Due to your hint ontitlesec, I am going to extract sections to own .tex files and include them into the main .tex, so I am no longer in need oftitlesec. I would accept your answer as correct if it would not be a plain answer to my question. Thanks a lot anyway. – zunder Dec 23 '14 at 02:29titlesecwhile allowing you to keep everything in one file, should you wish to do so. – cfr Dec 23 '14 at 03:49hyperrefandtitlesec, without modfiing thesectionbreakpart, would as well allow me to keep everything in one file. Adding aphantomsectionwas not a solution, but a workaround, which builed on a broken order of package imports. Beside that, I still had some positioning problems on some other subsections, which was still a problem of wrong order of imports. – zunder Dec 23 '14 at 11:16