如何避免某些章节出现边注

如何避免某些章节出现边注
\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}

当我使用上述方法时,每个部分都打印在单独的页面上。我想要这种类型的文本。是否可以连续打印,而不是分页打印

答案1

\newgeometry\restoregeometry负责分页。如果出于某种原因,您需要在页面中间临时更改页面布局(文本宽度、边距等),那么您可以使用changepage而是使用包。根据评论,也许这就是你想要的:

\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}

在此处输入图片描述

相关内容