Geometry 和 fncychap 包创建了一个丑陋的标题 - 我该如何纠正它?

Geometry 和 fncychap 包创建了一个丑陋的标题 - 我该如何纠正它?

我正在尝试使用该geometry包进行oneside布局。

然而,它显然对我的标题做了一些不愉快的事情。右下角有一个矩形被切掉了。没有绑定偏移,它看起来一切都很好。

\documentclass[a4paper, oneside, 11pt]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[Bjornstrup]{fncychap}
\usepackage[bindingoffset = 1 cm]{geometry}


%"Bugfix" for fncychap:
%Without this code there will be an overfull hbox by 10pt on every chapter
%I don't remember where I found this, but it seems to be unrelated to 
%the problem sice the header looks the same when commented out.     
%--------------------------------------------------------------------------

\makeatletter
  \renewcommand{\DOCH}{%
    \settowidth{\py}{\CNoV\thechapter}%
    \addtolength{\py}{-10pt}%     % Amount of space by which the
                                  % number is shifted right
    \fboxsep=0pt%
    \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
\kern-\myhi
    \kern-\py\raise20pt%
    \hbox{\color[gray]{.5}\CNoV\thechapter}%
\kern-\myhi
\\%
}

%-------------------------------------------------

\begin{document}

\chapter{Diskussion}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam 
erat, sed diam voluptua. 

\end{document}

我还想让页眉中的章节标题居中且更大。我该怎么做?

目前结果:

在此处输入图片描述

预期结果看起来更像这样:

在此处输入图片描述

多谢!

答案1

嗯,在第3.7 Bjornstrup 章节在包的文档中fncychap(使用 打开它texdoc fncychap),您可以找到使标题居中并放大的命令,例如使用命令

\ChTitleVar{\Huge\sffamily\bfseries\centering}

如果你改变调用包的顺序(geometry先调用包),如我的以下 MWE 所示,你的切出矩形消失了。

MWE(请参见我注释掉的命令\makeatletter,因为它不再需要并且未被关闭\makeatother

\documentclass[a4paper, oneside, 11pt]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

%\usepackage[Bjornstrup]{fncychap} % <==================================
\usepackage[% 
  bindingoffset=1cm,
  showframe
]{geometry}

\usepackage[Bjornstrup]{fncychap} % <===================================
\ChTitleVar{\Huge\sffamily\bfseries\centering} % <======================


%"Bugfix" for fncychap:
%Without this code there will be an overfull hbox by 10pt on every chapter
%I don't remember where I found this, but it seems to be unrelated to 
%the problem sice the header looks the same when commented out.     
%--------------------------------------------------------------------------

%\makeatletter
  \renewcommand{\DOCH}{%
    \settowidth{\py}{\CNoV\thechapter}%
    \addtolength{\py}{-10pt}%     % Amount of space by which the
                                  % number is shifted right
    \fboxsep=0pt%
    \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
\kern-\myhi
    \kern-\py\raise20pt%
    \hbox{\color[gray]{.5}\CNoV\thechapter}%
\kern-\myhi
\\%
}

%-------------------------------------------------

\begin{document}

\chapter{Diskussion}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam 
erat, sed diam voluptua. 

\end{document}

编译无误

在此处输入图片描述

相关内容