![如何让页眉、章节标题和图形扩展到页边距?](https://linux22.com/image/268568/%E5%A6%82%E4%BD%95%E8%AE%A9%E9%A1%B5%E7%9C%89%E3%80%81%E7%AB%A0%E8%8A%82%E6%A0%87%E9%A2%98%E5%92%8C%E5%9B%BE%E5%BD%A2%E6%89%A9%E5%B1%95%E5%88%B0%E9%A1%B5%E8%BE%B9%E8%B7%9D%EF%BC%9F.png)
我对以下页面布局感兴趣。
- 如何在页边距中添加页眉(最多到页边距)
- 是否可以从页边距开始章节标题
- 如何设置图形占据的边距。
我可以制作如下所示的 MWE
\documentclass[12pt,a4paper]{scrbook}
\usepackage[demo]{graphicx}
\usepackage[calcwidth]{titlesec}
%\titleformat{\section}[leftmargin]
%{\normalfont
%\sffamily\bfseries\filleft}
%{}{0pt}{}
%\titlespacing{\section}
%{4pc}{1.5ex plus .1ex minus .2ex}{1pc}
\newlength\mylen
\setlength\mylen{\dimexpr\oddsidemargin+1in+\hoffset\relax}
\titleformat{\section}
{\normalfont\Large\bfseries}
{\llap{\hspace*{-\mylen}\thesection\hfill}}{0em}{}
[{\makebox[\linewidth][l]{%
\hspace*{-\mylen}\rule{\dimexpr\textwidth+\mylen\relax}{1pt}}}]
%titleps is alternate for fancyhdr
%
\usepackage{titleps}
%\newpagestyle{main}[\small\sffamily]{
\newpagestyle{main}{
\widenhead[4pc][0pt]{4pc}{0pt} %for scrbook
%\widenhead[6pc][0pt]{0pt}{6pc} %for scrbook
%\widenhead[0pt][6pc]{6pc}{0pt} %for scrartcl
\headrule
\sethead
[\textbf{\thepage}]
[\textsl{Title of the Book}]
[]
{}
{\textsl{\chaptertitle}}
{\textbf{\thepage}}
}
\pagestyle{main}
\renewpagestyle{plain}[\small\sffamily]{
%\footrule
%\setfoot[\textbf{\thepage}]
\setfoot
[]
[]
[]
{}
{}
%{\textbf{\thepage}}
{}
%
\sethead
[\textbf{\thepage}]
[\textsl{Title of the Book}]
[]
{}
{}
{\textbf{\thepage}}
}
\begin{document}
\chapter{Chapter title}
\clearpage
\section{Section title}
skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf
\section{ Section title}
%
\begin{figure}[hb]
%\centering
\includegraphics[width=0.2\linewidth]{}
%\label{fig:p6a}
\caption{Figure caption}
\end{figure}
%
skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
\clearpage
\section{title}
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf
\end{document}
输出:偶数页
奇数页
我想将图形位置改为边距......
可能的解决方案 将图表并排摆放,溢出到外边距
答案1
此次修复包括几点:
1)\usepackage{calc}
2)新的标题定义使其左对齐:
\newcommand\mycaption[1]{\caption{%
\leftskip-\mylen#1\protect\rule{\textwidth-\mylen}{0in}}}
3)\leftskip
图形环境的边距
\begin{figure}[hb]
\setlength\leftskip{\leftskip-\mylen}
\includegraphics[width=0.2\linewidth]{}
\mycaption{Figure caption}
\end{figure}
警告:我没有修复第 3 页上现有的边距问题。
\documentclass[12pt,a4paper]{scrbook}
\usepackage[demo]{graphicx}
\usepackage{calc}
\usepackage[calcwidth]{titlesec}
%\titleformat{\section}[leftmargin]
%{\normalfont
%\sffamily\bfseries\filleft}
%{}{0pt}{}
%\titlespacing{\section}
%{4pc}{1.5ex plus .1ex minus .2ex}{1pc}
\newlength\mylen
\setlength\mylen{\dimexpr\oddsidemargin+1in+\hoffset\relax}
\titleformat{\section}
{\normalfont\Large\bfseries}
{\llap{\hspace*{-\mylen}\thesection\hfill}}{0em}{}
[{\makebox[\linewidth][l]{%
\hspace*{-\mylen}\rule{\dimexpr\textwidth+\mylen\relax}{1pt}}}]
%titleps is alternate for fancyhdr
%
\usepackage{titleps}
%\newpagestyle{main}[\small\sffamily]{
\newpagestyle{main}{
\widenhead[4pc][0pt]{4pc}{0pt} %for scrbook
%\widenhead[6pc][0pt]{0pt}{6pc} %for scrbook
%\widenhead[0pt][6pc]{6pc}{0pt} %for scrartcl
\headrule
\sethead
[\textbf{\thepage}]
[\textsl{Title of the Book}]
[]
{}
{\textsl{\chaptertitle}}
{\textbf{\thepage}}
}
\pagestyle{main}
\renewpagestyle{plain}[\small\sffamily]{
%\footrule
%\setfoot[\textbf{\thepage}]
\setfoot
[]
[]
[]
{}
{}
%{\textbf{\thepage}}
{}
%
\sethead
[\textbf{\thepage}]
[\textsl{Title of the Book}]
[]
{}
{}
{\textbf{\thepage}}
}
\begin{document}
\chapter{Chapter title}
\clearpage
\section{Section title}
skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf
\section{ Section title}
\newcommand\mycaption[1]{\caption{%
\leftskip-\mylen#1\protect\rule{\textwidth-\mylen}{0in}}}
%
\begin{figure}[hb]
\setlength\leftskip{\leftskip-\mylen}
%\centering
\includegraphics[width=0.2\linewidth]{}
%\label{fig:p6a}
\mycaption{Figure caption}
\end{figure}
%
skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
\clearpage
\section{title}
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf skjdfh jhsdf sdfk
sdfsdf
\end{document}