tufte-book documentclass 中偶数页上的全宽图形布局

tufte-book documentclass 中偶数页上的全宽图形布局

由于我的文档来自 Tufte-book 文档类,因此出现布局问题,我考虑了以下链接中提供的新代码,其中展示了旧代码和新代码:Tufte documentclass 中 \full{\printindex} 的布局问题tufte-book documentclass 中偶数页上的全宽图形和表格布局

由于在与问题“tufte-book documentclass 中偶数页上的全宽图形和表格布局”相关的答案中提出的用于解决表格布局问题的代码有效,因此我通过将序言中的“Table”替换为“Figure”,并使用下面的代码行来获得以下代码,以解决图形遇到的相同布局问题:

    \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

从而得到下面的代码来解决图形遇到的相同布局问题:

% !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}

得到的结果如下(见下图,图中插入了原始图像):

  • 第 17 页:图 1.1 应该是全宽的,但它只显示在文本的宽度上,
  • 第 20 页:以下图形确实是全宽的,但它们应该在文本的右侧对齐,但它们似乎在左侧对齐(表格也存在同样的问题),
  • 我希望图例宽度仅在 marginparwitdth 上,而不是 marginparwidth+marginparsep。我本可以设法减少标题文本的宽度,但它仍然在 marginparsep 边距中。我应该进行哪些更改才能获得此结果?

第 17 页 第 20 页

图 1.1[6][序曲风雅

上述答案解决了我的文档中所有表格和图形的问题,除了一个图形,我得到以下结果: 图13示例

问题出在哪里?下面是要插入的图: 图 2.13

答案1

更新标题宽度 = 边距宽度 & 图形高度。

图形(和表格)是浮动的:如果它们不适合页面上剩余的空间,它们就会写在下一页上。

在这种情况下,不会检测到从奇数页到偶数页或反之亦然的变化。

如果发生这种情况,请\newpage在大数字前添加以帮助检测并编译两次

是

是

% !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}{\linewidth+\marginparsep}\rlap{\hskip\oddshift\parbox{\marginparwidth}{\hskip0pt\@tufte@caption@font##1: ##2}}}%
    {\setlength{\oddshift}{-\marginparwidth- \marginparsep}\rlap{\hskip\oddshift\parbox{\marginparwidth}{\@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}{}{-\marginparwidth-\marginparsep}\captionatbottommargin}%
    {\begin{table}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\marginparsep}{}\captionatbottommargin}}       
    {\end{adjustwidth}\end{table}}    
        
\newenvironment{largefigure}{%
    \@tufte@checkoddpage%
    \ifthenelse{\boolean{@tufte@odd@page}}%
    {\begin{figure}[htbp!]\vspace*{-3ex}\begin{adjustwidth}{}{-\marginparwidth-\marginparsep}\captionatbottommargin}%changed <<<<<<
    {\begin{figure}[htbp!]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\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] 

\newpage % added <<<<<<<<<<<<<<<<<<<<<<<<<
\begin{largefigure}
    \includegraphics[width=\linewidth,keepaspectratio]{Figure_1.1.jpg}%
    \caption{1 Périodes de datation des diff\'{e}rentes copies originales de la Pi\`{e}ce d'Orgue BWV 532.}%
    \label{fig:Synoptique}%
\end{largefigure}            

\newpage  % added <<<<<<<<<<<<<<<<<<<<<<<<<
\begin{largefigure}
    \includegraphics[width=\linewidth,keepaspectratio]{Figure_1.1.jpg}%
    \caption{2 Périodes de datation des diff\'{e}rentes copies originales de la Pi\`{e}ce d'Orgue BWV 532.}%
    \label{fig:Synoptique2}%
\end{largefigure}
\newpage  % added <<<<<<<<<<<<<<<<<<<<<<<<<

11. \kant[9]

\begin{largefigure}
    \includegraphics[width=\linewidth,keepaspectratio]{Preludio.jpg}%
    \caption{En--tête du prélude inscrit par Lorenz Sichart en 1740.}%
    \label{fig:prelude}%
\end{largefigure}


12. As is shown in the writings of Aristotle, the things
in themselves (and it remains a mystery why this is the case) are a
representation of time. Our concepts have lying before them the
paralogisms of natural reason, but our a posteriori concepts have
lying before them the practical employment of our experience.     

\begin{largefigure}
\includegraphics[width=\linewidth,keepaspectratio]{Fuga.jpg}%
\caption{En--tête de la fugue inscrit par Lorenz Sichart en 1740.}%
\label{fig:fugue}%
\end{largefigure}

13. \kant[13]
                    
\end{document}

更新二 非常高大、宽阔的身影。

该图在两个方向上都溢出了页面。最好将其缩小(使用scale)并使用单个页面。

尝试

\newpage % added <<<<<<<<<<<<<<<<<<<<<<<<<
\begin{largefigure}
    \includegraphics[scale=0.45]{Figure13.jpg}% changed <<<<<<<<<<
    \caption{Plan formed du passage introductif (mes \`{a} 16) du pr\`{e}lude BWV 532.}%
    \label{fig:Plan}%
\end{largefigure}
\newpage  % added <<<<<<<<<<<<<<<<<<<<<<<<<

这是更新 II 的完整代码。

% !TeX TS-program = xelatex     

\documentclass[a4paper,nobib,twoside,symmetric,justified,marginals=raggedouter, notoc]{tufte-book}

%********************************************************************************  UPDATED II
\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}{\linewidth+\marginparsep}\rlap{\hskip\oddshift\parbox{\marginparwidth}{\hskip0pt\@tufte@caption@font##1: ##2}}}%
    {\setlength{\oddshift}{-\marginparwidth- \marginparsep}\rlap{\hskip\oddshift\parbox{\marginparwidth}{\@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}{}{-\marginparwidth-\marginparsep}\captionatbottommargin}%
    {\begin{table}[!htbp]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\marginparsep}{}\captionatbottommargin}}       
    {\end{adjustwidth}\end{table}}    
        
\newenvironment{largefigure}{%
    \@tufte@checkoddpage%
    \ifthenelse{\boolean{@tufte@odd@page}}%
    {\begin{figure}[htbp!]\vspace*{-3ex}\begin{adjustwidth}{}{-\marginparwidth-\marginparsep}\captionatbottommargin}%changed <<<<<<
    {\begin{figure}[htbp!]\vspace*{-3ex}\begin{adjustwidth}{-\marginparwidth-\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] 

\newpage % added <<<<<<<<<<<<<<<<<<<<<<<<<
\begin{largefigure}
    \includegraphics[scale=0.45]{Figure13.jpg}%
    \caption{Plan formed du passage introductif (mes \`{a} 16) du pr\`{e}lude BWV 532.}%
    \label{fig:Plan}%
\end{largefigure}
\newpage  % added <<<<<<<<<<<<<<<<<<<<<<<<<

10. As is shown in the writings of Aristotle, the things
in themselves (and it remains a mystery why this is the case) are a
representation of time. Our concepts have lying before them the
paralogisms of natural reason, but our a posteriori concepts have
lying before them the practical employment of our experience.            

\newpage  % added <<<<<<<<<<<<<<<<<<<<<<<<<
\begin{largefigure}
    \includegraphics[scale=0.45]{Figure13.jpg}%
    \caption{Plan formed du passage introductif (mes \`{a} 16) du pr\`{e}lude) BWV 532.}%
    \label{fig:Synoptique2}%
\end{largefigure}

11. \kant[9]

\end{document}
            

Z Z

相关内容