Following layout problems with my document coming from a Tufte-book documentclass, I took into account the new code presented in the following link, which presents the old and the new code: layout problem with \full{\printindex} in Tufte documentclass and Fullwidth figure and table layout on even page in tufte-book documentclass.
As the code proposed in the answer relating to question "Fullwidth figure and table layout on even page in tufte-book documentclass" to solve the table layout problem works, I have taken this one by replacing "Table" by "Figure" in the preamble with lines of code here – below: so as to obtain the following code in order to solve the same layout problems encountered with figures:
\newenvironment{largefigure}{%
\@tufte@checkoddpage%
\ifthenelse{\boolean{@tufte@odd@page}}%
{\begin{figure}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{}{}\captionatbottommargin}
{\begin{figure}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\marginparsep}{\marginparsep}\captionatbottommargin}}
{\end{adjustwidth}\end{figure}}
\makeatother
So as to obtain the following code in order to solve the same layout problems encountered with figures:
% !TeX TS-program = xelatex
\documentclass[a4paper,nobib,twoside,symmetric,justified,marginals=raggedouter, notoc]{tufte-book}
\makeatletter
\newlength{\oddshift}
\newcommand{\captionatbottommargin}{% from https://tex.stackexchange.com/a/229419/161015
\long\def\@caption##1[##2]##3{%
\par
\addcontentsline{\csname ext@##1\endcsname}{##1}%
{\protect\numberline{\csname the##1\endcsname}{\ignorespaces ##2}}%
\begingroup
\@parboxrestore%
\if@minipage\@setminipage\fi%
\normalsize
\@makecaption{\csname fnum@##1\endcsname}{\ignorespaces ##3}\par
\endgroup}
\long\def\@makecaption##1##2{%
\vskip\abovecaptionskip%
\@tufte@checkoddpage%
\ifthenelse{\boolean{@tufte@odd@page}}%
{\setlength{\oddshift}{\textwidth}\rlap{\hskip\oddshift\parbox{\marginparwidth+\marginparsep}{\hskip0pt\@tufte@caption@font##1: ##2}}}%
{\setlength{\oddshift}{-\marginparwidth- \marginparsep}\rlap{\hskip\oddshift\parbox{\marginparwidth+\marginparsep}{\@tufte@caption@font##1: ##2}}}%
\vskip\belowcaptionskip%
}%
\let\caption\@tufte@orig@caption%
\let\label\@tufte@orig@label}
\newenvironment{largetable}{%
\@tufte@checkoddpage%
\ifthenelse{\boolean{@tufte@odd@page}}%
{\begin{table}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{}{}\captionatbottommargin}%
{\begin{table}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\marginparsep} {\marginparsep}\captionatbottommargin}}
{\end{adjustwidth}\end{table}}
\newenvironment{largefigure}{%
\@tufte@checkoddpage%
\ifthenelse{\boolean{@tufte@odd@page}}%
{\begin{figure}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{}{}\captionatbottommargin}
{\begin{figure}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\marginparsep}{\marginparsep}\captionatbottommargin}}
{\end{adjustwidth}\end{figure}}
\makeatother
\usepackage{booktabs}
\geometry{% normal pages
paperheight =297mm, paperwidth = 210mm, %layout=a4paper
layoutheight =240mm,layoutwidth =170mm,
textheight=38\baselineskip,
headheight=\baselineskip,
left=15mm, % right will be the same because of symmetric
bindingoffset= 5mm, % add space for binding
textwidth=90mm,
top=14mm,
marginparsep=6mm, marginparwidth=40mm,
includehead,
layoutvoffset= 28.5mm,layouthoffset= 20mm, % 297-240 = 57mm 210-170 = 40mm ->> to center smaller layout in a4
showframe=true,
showcrop=true }
\renewenvironment{fullwidth}
{\newgeometry{% full width pages
layoutheight =240mm,layoutwidth =170mm,
textheight=38\baselineskip,
headheight=\baselineskip,
left=15mm, % right will be the same because of symmetric
bindingoffset= 5mm, % add space for binding
textwidth=136mm, % 90+ 6+ 40
top=14mm,
marginparsep=0mm, marginparwidth=0mm, %changed to full width <<<<<<<<<<
includehead,
layoutvoffset= 28.5mm,layouthoffset= 20mm, % 297-240 = 57mm 210-170 = 40mm ->> to center smaller layout in a4
showframe=true,
showcrop=true }
\fancyhfoffset[LE]{0pt}
\fancyhfoffset[RO]{0pt}
}
{\restoregeometry}%
\usepackage{kantlipsum} % dummy text added
\RequirePackage{showframe} % margin lines <<<<<<<<<<<<<<<<<<<<<<<<<
\renewcommand\ShowFrameLinethickness{0.1pt}
\renewcommand\ShowFrameColor{\color{red}}
\newcommand{\textls}[2][5]{%
\begingroup\addfontfeatures{LetterSpace=#1}#2\endgroup
}
\renewcommand{\allcapsspacing}[1]{\textls[15]{#1}}
\renewcommand{\smallcapsspacing}[1]{\textls[10]{#1}}
\renewcommand{\allcaps}[1]{\textls[15]{\MakeTextUppercase{#1}}}
\renewcommand{\smallcaps}[1] {\smallcapsspacing{\scshape\MakeTextLowercase{#1}}}
\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{#1}}}
\usepackage{fontspec}
\usepackage{libertine} %<<<<<<<<<<<<<<<<
\setsansfont{TeX Gyre Heros}[Scale=MatchUppercase]
\usepackage{xspace}
\newcommand{\monthyear}{%
\ifcase\month\or janvier\or f\'{e}vrier\or mars\or avril\or mai\or juin\or
juillet\or ao\^{u}t\or septembre\or octobre\or novembre\or
d\'{e}cembre\fi\space\number\year
}
\newcommand{\blankpage}{\newpage\hbox{}\thispagestyle{empty}\newpage}
\usepackage[english,french]{babel}
\frenchbsetup{StandardLayout=true}
\addto\captionsfrench{\def\tablename{Tableau}}
\addto\captionsfrench{\def\figurename{Figure}}
\frenchbsetup{IndentFirst=false}
\usepackage{csquotes}
\begin{document}
\frenchspacing
\mainmatter
9. \kant[9]
\begin{largefigure}
\includegraphics[width=\linewidth]{Figure_1.1.pdf}%
\caption{Périodes de datation des diff\'{e}rentes copies originales de la Pi\`{e}ce d'Orgue BWV 532.}%
\label{fig:Synoptique}%
\end{largefigure}
11. \kant[11]
\end{document}
The results obtained are as follows (see the figures below, with the original images inserted in the figures):
- Page 17: Figure 1.1 should be full width, but it is displayed only on the width of the text,
- Page 20: the following figures are indeed in full width, but they should be aligned on the right on the text, but it seems that they are justified on the left (the same problem is observed for the tables),
- I would like the legend width to be only on marginparwitdth and not marginparwidth+marginparsep. I would have managed to reduce the width of the caption text, but it remains in the marginparsep margin. What should I change to get this result?
The answer above solved the problem for all tables and figures in my document, except for one figure where I get the following result:
Where can the problem come from? Here is the figure to insert:
Best Answer
UPDATED Captions width = marginparwidth & tall figures.
Figures (and tables) are floating: if they don't fit in the space left on the page, they are written on the next page.
In this case, the change from odd to even page or vice versa is not detected.
If this happens add
\newpage
before the big figure to help the detection and compile twice.UPDATE II a very tall and wide figure.
The figure overflows the page in both directions. It is best to reduce it (with
scale
) and use a single page for it.Try
This is the full code of update II.