2
\documentclass[a4paper]{book}
\usepackage{latexsym,amsmath,amssymb}
\usepackage[top=2cm,bottom=1.3cm,left=4cm,right=5cm,bindingoffset=0.25in,heightrounded,marginparwidth=4cm,marginparsep=3mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{marginnote}
\usepackage{xcolor}
\usepackage{titlesec}


\colorlet{sectitlecolor}{red!60!black}
\colorlet{sectboxcolor}{cyan!30}
\colorlet{secnumcolor}{orange}

\titleformat{\section}
{\normalfont\Large\bfseries\color{sectitlecolor}}{\llap{\makebox[3em][l]{\colorbox{sectboxcolor}{\textcolor{secnumcolor}{\thesection}}}}}{0em}{} 
% % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{document}
    \chapter{A test chapter}
    This is the first chapter
    \newgeometry{top=2cm,bottom=1.3cm,left=4cm,right=2cm}
    \section{First section}
    This is the first section without marginal note. 
    \restoregeometry 
    \section{Second section}
    This is the second section with marginal note.\reversemarginpar\marginnote{\textcolor{blue}{This is a margin note.}} 
    \newgeometry{top=2cm,bottom=1.3cm,left=4cm,right=2cm}
    \section{Third section}
    This is the third section without marginal note. 
    \restoregeometry 
    \section{Fourth section}
    This is the fourth section with marginal note.\reversemarginpar\marginnote{\textcolor{blue}{This is a margin note.}}
\end{document}

When I use the above, each section is printed in separate pages. I want this type of texts. Is it possible to print continuously, not in separate pages

Gonzalo Medina
  • 505,128

1 Answers1

3

\newgeometry and \restoregeometryare responsible for the page breaks. If, for some reason, you need to temporarily change the page layout (text width, margins, etc.) mid-page, then you can use the environments provided by the changepage package instead. According to comments, maybe this is what you want:

\documentclass[a4paper]{book}
\usepackage{latexsym,amsmath,amssymb}
\usepackage[top=2cm,bottom=1.3cm,left=4cm,right=5cm,bindingoffset=0.25in,heightrounded,marginparwidth=4cm,marginparsep=3mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{marginnote}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{multicol}

\colorlet{sectitlecolor}{red!60!black}
\colorlet{sectboxcolor}{cyan!30}
\colorlet{secnumcolor}{orange}

\titleformat{\section}
{\normalfont\Large\bfseries\color{sectitlecolor}}{\llap{\makebox[3em][l]{\colorbox{sectboxcolor}{\textcolor{secnumcolor}{\thesection}}}}}{0em}{} 

\begin{document}
    \chapter{A test chapter}
    This is the first chapter
    \section{First section}
    This is the first section without marginal note. 
    \section{Second section}
    This is the second section with marginal note.  \reversemarginpar\marginnote{\textcolor{blue}{This is a margin note.}} 
    \section{Third section}
    This is the third section without marginal note. 
    \section{Fourth section}
    This is the fourth section with marginal note.\reversemarginpar\marginnote{\textcolor{blue}{This is a margin note.}}
  \begin{multicols}{2}[\section{Exercises}]
  Some test text goes here to illustrate two-column mode and here we add some more words  test text goes here to illustrate two-column mode and here we add some more words  test text goes here to illustrate two-column mode and here we add some more words
  \end{multicols}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
  • Well, I got the answer. In book class, how to increase the left side space in odd numbered page and right side space in even numbered page for the binding purpose. How to change the command in \usepackage[top=2cm,bottom=1.3cm,left=4cm,right=5cm,bindingoffset=0.25in,heightrounded,marginparwidth=4cm,marginparsep=3mm]{geometry} – SG Sekaran Sep 21 '15 at 16:57
  • @SGSekaran you already have bindingoffset=0.25in; you can increase the value, if required. – Gonzalo Medina Sep 21 '15 at 17:09
  • I think he needs temporally increase marginarea for the margin note and go back to normal textwidth size...I did this before ..dont remember...It is a package changepage .. https://www.ctan.org/tex-archive/macros/latex/contrib/changepage ...maybe this help http://tex.stackexchange.com/questions/27272/how-can-i-draw-a-line-from-margin-to-margin-if-the-text-width-has-been-adjusted – Levan Shoshiashvili Sep 21 '15 at 20:59
  • @LevanShoshiashvili Perhaps, you're right. I added a remark about changepage in my answer. Thanks. – Gonzalo Medina Sep 21 '15 at 22:37
  • @SGSekaran I updated my answer with new information that can be of interest for you. – Gonzalo Medina Sep 21 '15 at 22:37