Komaclass scrbook 中的 Flipbook 图像放置

Komaclass scrbook 中的 Flipbook 图像放置

我想在文档 ( scrbook) 的右上角或右下角添加一本翻页书。我已经设法在所有页面上插入图片,并在文件名中添加递增的数字。只需提一下:Komaclasses 会抱怨,fancyhdr这就是我不想使用它的原因。这同样适用于自行flipbook加载的包fancyhdr

我很难找到正确的位置。考虑遵循 MWE 并查看编译结果:

\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{showframe}
\usepackage{picture}
\usepackage{scrlayer-scrpage}

\makeatletter
\rohead*{%
  \if@mainmatter
  \begin{picture}(-\marginparsep,\headheight)
    \put(0,-\headsep){\includegraphics[width=\marginparwidth,height=37.4pt]{example-image-a}}
  \end{picture}
  \else\fi
}
\makeatother

\begin{document}
\mainmatter
\chapter{title}
\begin{description}
  \item[headheight] \the\headheight 
  \item[headsep] \the\headsep 
  \item[marginparwidth] \the\marginparwidth 
  \item[marginparsep] \the\marginparsep 
\end{description}

\paragraph{Intended size and placement of flipbook image:}
\begin{itemize}
  \item width of image = marginparwidth
  \item height of image = headsep + headheight
  \item lower left corner of image should be at the top left corner of the margin notes
    box (compare showframe)
  \item Alternative placement: top left corner of image should be at the lower
    left corner of the margin notes box
\end{itemize}
\end{document}

在此处输入图片描述

我剩下的问题是,如何在不迭代图片环境和 put 命令的值的情况下放置图像。另外,我如何避免这个问题呢Package scrlayer-scrpage Warning: \headheight too low

答案1

我将为翻页书声明一个自己的图层,该图层可以添加到页面样式scrheadings和中plain.scrheadings。然后您仍然可以将\ohead\rohead用于其他内容。

\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{showframe}
\usepackage{picture}

\usepackage{scrlayer-scrpage}
\makeatletter
\DeclareNewLayer[
  background,
  oddpage,
  textarea,
  addhoffset=\textwidth+\marginparsep,
  width=\marginparwidth,
  height=\headsep+\headheight,
  align=b,
  mode=picture,
  contents={%
    \if@mainmatter
      \putLL{\includegraphics[width=\layerwidth,height=\layerheight]{example-image-a}}%
    \fi
  }
]{flipbook.odd}
\makeatother

\AddLayersToPageStyle{plain.scrheadings}{flipbook.odd}
\AddLayersToPageStyle{scrheadings}{flipbook.odd}

\begin{document}
\mainmatter
\chapter{title}
\begin{description}
  \item[headheight] \the\headheight 
  \item[headsep] \the\headsep 
  \item[marginparwidth] \the\marginparwidth 
  \item[marginparsep] \the\marginparsep 
\end{description}

\paragraph{Intended size and placement of flipbook image:}
\begin{itemize}
  \item width of image = marginparwidth
  \item height of image = headsep + headheight
  \item lower left corner of image should be at the top left corner of the margin notes
    box (compare showframe)
  \item Alternative placement: top right corner of image should be at the lower
    left corner of the margin notes box
\end{itemize}
\end{document}

在此处输入图片描述

相关内容