为了修复新版本软件包中的一个错误sidenotes
(此处报告错误),我搭建的环境如下:
\newenvironment{autoadjustwidth}[2]%
{\ifthenelse{\boolean{@twoside}}%
{\begin{adjustwidth*}{#1}{#2}}%
{\begin{adjustwidth}{#1}{#2}}%
}%
{\ifthenelse{\boolean{@twoside}}%
{\end{adjustwidth*}}%
{\end{adjustwidth}}%
}%
环境autoadjustwidth
会尝试区分书籍/双页/对称和文章/“所有页面相似”样式。我可以依靠它来@twoside
检测这一点吗?
针对一种特殊情况的完整 MWE,其中图形填充了文本列和边距:
%\documentclass{article}
\documentclass{book}
\usepackage{lipsum}
\usepackage{ifthen}
\usepackage{changepage}
\usepackage{mwe}
\usepackage{graphicx}
\makeatletter
\newlength{\overhang}
\setlength{\overhang}{\marginparwidth}
\addtolength{\overhang}{\marginparsep}
\newlength{\full}
\setlength{\full}{\textwidth}
\addtolength{\full}{\overhang}
\newenvironment{autoadjustwidth}[2]%
{\ifthenelse{\boolean{@twoside}}%
{\begin{adjustwidth*}{#1}{#2}}%
{\begin{adjustwidth}{#1}{#2}}%
}%
{\ifthenelse{\boolean{@twoside}}%
{\end{adjustwidth*}}%
{\end{adjustwidth}}%
}%
\makeatother
\renewenvironment{figure*}[1][htbp]{%
\begin{figure}[#1]%
\begin{autoadjustwidth}{}{-\overhang}}%
{\end{autoadjustwidth}%
\end{figure}}%
\begin{document}
\lipsum[1]
\begin{figure*}
\includegraphics[width=\full, height=100pt]{example-image-a}
\end{figure*}
\lipsum[3]
\newpage
\lipsum[1]
\begin{figure*}
\includegraphics[width=\full, height=100pt]{example-image-a}
\end{figure*}
\lipsum[3]
\end{document}
答案1
@twoside
是检测文档是否为双面的布尔值。它是 latex 内核的一部分。如果您加载,etoolbox
则可以使用以下命令进行测试\ifbool
:
\makeatletter
\newenvironment{autoadjustwidth}[2]%
{\ifbool{@twoside}%
{\begin{adjustwidth*}{#1}{#2}}%
{\begin{adjustwidth}{#1}{#2}}%
}%
{\ifbool{@twoside}%
{\end{adjustwidth*}}%
{\end{adjustwidth}}%
}%
\makeatother
请注意,这些scr
类有一个额外的选项设置twoside=semi
。这会导致混合排版方案,具有一些双面功能,但边注始终放在同一侧。用 测试此值\ifbool{@semitwoside
。twoside=semi
选项导致\@twosidetrue
和\@semitwosidetrue
;twoside
或twoside=true
给出\@twosidetrue
和\@semitwosidefalse
;oneside
或twoside=false
给出\@twosidefalse
和\@semitwosidefalse
。