# How to switch between two different marginparwidth size?

I like this book layout stewartcalculus, so I want to mimic some of its layout. In this topic I want to start from the page number 5. The following is the screenshot: (hopely don't break the copyright :D)

The upper part has shorter marginparwidth compared to the Exercise part. I am interested how the author of this book modified the marginparwidth back and forth, from the main content to the exercise.

EDIT 1:

Or he wrote it using softwares other than LaTeX ? InDesign or something like that?

-
I think you mean that the upper part has a larger left margin compared to the exercise part, rather than a shorter marginparwidth. Also, would it be far to say that your question is "How can I recreate this layout in TeX?" rather than "How did Stewart create this layout?" As a textbook author (though a fledgeling one) I'm pretty sure he did not provide the camera-ready manuscript. –  Matthew Leingang Dec 2 '10 at 13:54
ConTeXt solution appearing in 3...2...1... –  Matthew Leingang Dec 2 '10 at 14:31
This can easily be hacked in LaTeX as well. Nothing impossible, just the answers button would need the hyperref or insdljs. It is a very well designed book. –  Yiannis Lazarides Dec 8 '10 at 15:51
@Mathew Sorry if I sound stupid but what is 3...2...1 ? –  Yiannis Lazarides Dec 8 '10 at 15:52
As Matthew has commented, the question is actually not about \marginpar, but about changing the "margins" in the middle of a page. The correct tag therefore is indentation, see meta.tex.stackexchange.com/questions/2093/…. –  lockstep Dec 26 '11 at 22:23

There are various ways to change the margins on-the-fly or to overwrite them.
If the exercises are in a box without page break you can use simply \hspace*:

\documentclass{article}
\usepackage{lipsum,multicol}
\begin{document}
\lipsum[1]

\vfill
\noindent\hspace*{-3cm}%
\begin{minipage}{\dimexpr\textwidth+3cm}
\begin{multicols}{2}
\lipsum[1]
\end{multicols}
\end{minipage}
\end{document}

-
@Ulrike, thanks for your answer. Is there a better way to make a page break for the exercise instead of put \pagebreak manually? –  xport Dec 2 '10 at 14:25
minipage cannot determine the page break automatically. –  xport Dec 7 '10 at 0:31

In the Tufte-LaTeX document class, we achieve that affect by defining a fullwidth environment. The definition of this environment uses the changepage package (or an earlier version named chngpage). A simplified version looks like this:

\documentclass{article}

\usepackage{multicol}% for multiple columns inside the fullwidth environment

% The following code should be used *after* any changes to the margins and
% page layout are made (e.g., after the geometry package has been loaded).
\newlength{\fullwidthlen}
\setlength{\fullwidthlen}{\marginparwidth}

\newenvironment{fullwidth}{%
}{%
}

\usepackage{lipsum}% provides dummy text

\begin{document}

\lipsum[1]

\begin{fullwidth}
\begin{multicols}{2}
\lipsum[2]
\end{multicols}
\end{fullwidth}

\lipsum[3]

\end{document}

-
Thanks @godbyk. However, it does not work for twoside documents; even and odd numbered pages should be symmetrical. –  xport Dec 6 '10 at 7:20
@xport: What exactly do you mean? I tried it and it seems to work fine, I get the narrow margin on one side on odd pages and on the other side on the even pages. –  Jan Hlavacek Dec 6 '10 at 10:57
@jan, try change the preamble by inserting twoside option into the \documentclass optional argument and change \lipsum[2] to \lipsum[1-20]. See the result. :-) –  xport Dec 6 '10 at 13:46
@xport: I see. I was only trying to have several pages, each with a short wide paragraph, but I did not try to have a wide section spanning several pages. –  Jan Hlavacek Dec 6 '10 at 17:44
@xport: The code in the tufte-latex package does allow for symmetric and asymmetric page layouts. I stripped that part of the code out since the example PDF you provided uses an asymmetrical layout. You can view the actual code, if you like: code.google.com/p/tufte-latex/source/browse/trunk/… –  godbyk Dec 7 '10 at 23:10

The document was turned into a PDF using Distiller, which I guess means it wasn't typeset using a Tex technology. I wonder if those formulae could have been generated using Framemaker's Equation Editor.

In Context, the narrower start-stop environment would be the way to do this:

\startnarrower[left=1.5in]
Upper part
\stopnarrower
Exercises


The narrower can be use with negative values to narrow the margins, rather than the text.

-
thanks for the answer. However, I am not using ConTeXt. :-) –  xport Dec 7 '10 at 0:28
@xport: You didn't say that! Maybe the book was prepared with Context.... Do look at meta.tex.stackexchange.com/questions/524/… –  Charles Stewart Dec 7 '10 at 9:02

The layout of the pages is somewhat reminiscent of some of the tufte-latex document classes. They both have the same wide margin, with notes, figures and tables, and tufte-latex classes do have a way to insert material that will use the full width of the page. I am sure Stewart did not use these, since his books predate tufte-latex, as far as I know.

-

how about something simple like that:

\documentclass[10pt]{book}
\usepackage{lipsum}
\usepackage[top=5cm,left=2cm,right=2cm,bottom=5cm,a4paper]{geometry}
% wide left margin environment
\newenvironment{foo}{\par\leftskip=4cm \rightskip=0cm}{\par}

\begin{document}
\begin{foo}
\section{plo}
\lipsum[5]\lipsum[5]
\section{plo}
\lipsum[5]\lipsum[5]
\end{foo}
\section*{Exercice}
\lipsum[1]
\begin{foo}
\section{plo}
\lipsum[5]\lipsum[5]
\section{plo}
\lipsum[5]\lipsum[5]
\end{foo}
\end{document}

-
Thanks @pluton. However, it does not work for twoside documents; even and odd numbered pages should be symmetrical. –  xport Dec 7 '10 at 2:26
an conditional "if" statement may be able to do that. Otherwise, a deep look into the tufte class as already mentioned may help. –  pluton Dec 7 '10 at 3:02
@xport, please replace \newenvironment{foo}{\par\leftskip=4cm \rightskip=0cm}{\par} by \makeatletter\newenvironment{foo{\par\if@twoside\ifodd\c@page\leftskip=4cm \rightskip=0cm\else\leftskip=0cm\rightskip=4cm\fi\fi}{\par}\makeatother; this will work for twoside documents. Well, no, this is not working well with equations :( –  pluton Dec 7 '10 at 3:48
this is not working well at all, forget this. –  pluton Dec 7 '10 at 3:58
If you want to make a modification, just press edit button right below your answer. And if you want to remove your comment, just press the delete button below your comment. :-) Anyway, thank for your effort. –  xport Dec 7 '10 at 4:08
show 1 more comment

Here is a hack on top of the tufte-book class in order to keep it simple. Two environments are defined one for oneside pages and another for double sided pages called adjustmargins use negative values to pull towards the page edges. The correct way is to redefine large sections of the class or even write one from scratch (I would do the latter as the tufte-class puts all captions and citations in the margins which is really not suited in this case). Code is rather long but prints a full page to see the possibilities. Code needs work. I normally code like a sketch, get as quickly as possible to what I want and then go back and re-factor. For example in a final version, I would code the button for answers either using hyperef or insdljs and redefine all page dimensions.

\documentclass[justified]{tufte-book}

\usepackage[utf8]{inputenc} % set input encoding (not needed with XeLaTeX)

\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{soul}
\title{Thanks to Steward }
\author{The Author}

\begin{document}
\maketitle

\noindent\parbox{12.7cm}{This coordinate system is called the rectangular coordinate system or the Cartesian
coordinate system in honor of the French mathematician René Descartes (1596–1650),
even though another Frenchman, Pierre Fermat (1601–1665), invented the principles of
analytic geometry at about the same time as Descartes. The plane supplied with this coordinate system is called the coordinate plane or the Cartesian plane and is denoted by .
The  and axes are called the coordinate axes and divide the Cartesian plane into
four quadrants, which are labeled I, II, III, and IV in Figure 1. Notice that the first quadrant consists of those points whose  and coordinates are both positive.}

\begin{fullwidth}
\fboxrule1.0pt
\fboxsep10pt

\noindent\color{red}\framebox{\parbox{12.7cm}{\color{black}

\textbf{\textcolor{red}{\textsf{Parallel and Perpendicular Lines}}}
\begin{enumerate}
\itemsep-5pt
\item Two nonvertical lines are parallel if and only if they have the same slope.
\item Two lines with slopes $m_1$ and $m_2$ are perpendicular if and only if $m_1m_2=-1$;  that is, their slopes are negative reciprocals:
$m_{2}=-\frac{1}{m_{1}}$

\end{enumerate}
}}

\color{black}

\parindent=0pt
\vspace{8pt}
\noindent{\color{blue}{\textsf{\textbf{EXAMPLE}}}} 5 Find an equation of the line through the point that is parallel to the line\\
$$4x+6y+5=0$$.

\smallskip
\textsf{SOLUTION} The given line can be written in the form
\medskip

\hskip4cm$$y=-\frac{2}{3}x-\frac{5}{6}$$
\end{fullwidth}

\makeatletter
\begin{list}{}{%
\topsep\z@%
\listparindent\parindent%
\parsep\parskip%
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#1}}%
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#2}}%
}
\item[]}{\end{list}}

\begin{list}{}{%
\topsep\z@%
\listparindent\parindent%
\parsep\parskip%
\checkoddpage
\ifoddpage % odd numbered page
\@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#1}}%
\@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#2}}%
\else % even numbered page
\@ifmtarg{#2}{\setlength{\leftmargin}{\z@}}%
{\setlength{\leftmargin}{#2}}%
\@ifmtarg{#1}{\setlength{\rightmargin}{\z@}}%
{\setlength{\rightmargin}{#1}}%
\fi
}
\item[]}{\end{list}}

\makeatother

\vfill
\rule{17.2cm}{.4pt}

There are no engineers in the hottest parts of hell, because the existence of a 'hottest part' implies a temperature difference, and any marginally competent engineer would immediately use this to run a heat engine and make some other part of hell comfortably cool.  This is obviously impossible.