章节标题周围有紧密的黑框吗?

章节标题周围有紧密的黑框吗?

我希望在章节标题周围制作一个紧密的黑框,最好1pt每边只留有空白。到目前为止,我的最佳结果是soul

使用“灵魂”包

但是,您会注意到底部的边距太大。此外,每个奇数页的顶部都会重复突出显示:

使用“灵魂”包

做这些事情的聪明方法是什么?我不介意使用其他方法soul,它似乎是一个很好的解决方案。

MWE 如下。请注意,您需要米科达克斯字体(或者任何 TTF 字体?)在FONTLOCATION

\documentclass[book,dvipsnames]{memoir}

\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{anyfontsize}
\usepackage{soul}
\sethlcolor{black}

%% Change height of highlight
\makeatletter
 \def\SOUL@hlpreamble{%
 \setul{}{2ex}%
 \let\SOUL@stcolor\SOUL@hlcolor
 \SOUL@stpreamble
 }
\makeatother

\newfontfamily{\archivo}[Path=/FONTLOCATION]{Mikodacs.ttf}

\usepackage{lipsum} %% For dummy text

%% Chapterstyle
\makechapterstyle{lucknerto}{%
\setlength{\beforechapskip}{-2\onelineskip}%
\setlength{\afterchapskip}{2\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\large\sffamily\bfseries}%
\renewcommand*{\afterchapternum}{}%
\renewcommand{\printchaptertitle}{\centering\archivo\color{White}\fontsize{23}{27.6}\selectfont\MakeUppercase}
}
\chapterstyle{lucknerto} %% enable

%% Pagestyle 
\makepagestyle{luckner}%
\makeevenhead{luckner}{}{\small{{\MakeUppercase{book title}}}}{} 
\makeoddhead{luckner}{}{\small{{\MakeUppercase{\leftmark}}}}{}
\makeevenfoot{luckner}{\large{\thepage}}{}{}
\makeoddfoot{luckner}{}{}{\large{\thepage}}
\pagestyle{luckner} %% enable

\begin{document}
\chapter{\hl{Foobar}}
\lipsum[1-20]
\end{document}

答案1

该风格非常简单,tcolorbox并且有一个特殊\tcbox命令,可以根据个人喜好进行修改。

“困难”在于理解memoir章节标题的作用。我不得不改变\printchaptertitle以提出论点(这是通常的情况),而不是使用移动论点。

\documentclass[book,dvipsnames]{memoir}

\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{anyfontsize}
\usepackage{soul}
\usepackage{tcolorbox}
\sethlcolor{black}

%% Change height of highlight
\makeatletter
 \def\SOUL@hlpreamble{%
 \setul{}{2ex}%
 \let\SOUL@stcolor\SOUL@hlcolor
 \SOUL@stpreamble
 }
\makeatother

\newfontfamily{\archivo}[Path=/FONTLOCATION]{Micodacs.ttf}

%\newfontfamily{\archivo}{Liberation Sans}

\usepackage{lipsum} %% For dummy text

\tcbset{chapterhead/.style={%
    fontupper=\archivo\fontsize{23}{27.6}\selectfont,
    left skip=1ex, % for example
    nobeforeafter, %no spacing before and after the box etc
    halign=center, % horizontal align within box, can be omitted
    valign=center, % vertical align within box, can be omitted
    colback=black, % black background colour
    size=tight, % tight box
    colupper=white, % white foreground colour
  }
}

\newtcbox{\blackbox}[1][]{%
  chapterhead,
  #1,
}

%% Chapterstyle
\makechapterstyle{lucknerto}{%
\setlength{\beforechapskip}{-2\onelineskip}%
\setlength{\afterchapskip}{2\onelineskip}%
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapternamenum}{}%
\renewcommand*{\chapnumfont}{\normalfont\large\sffamily\bfseries}%
\renewcommand*{\afterchapternum}{}%
\renewcommand{\printchaptertitle}{\centering\tcbox[nobeforeafter,halign=center,valign=center,colback=black,size=tight,colupper=white,code={\noexpand\MakeUppercase}]}%\centering\archivo\color{blue}\fontsize{23}{27.6}\selectfont\MakeUppercase}
\renewcommand{\printchaptertitle}[1]{\centering\blackbox{\MakeUppercase{##1}}}%\centering\archivo\color{blue}\fontsize{23}{27.6}\selectfont\MakeUppercase}
}
\chapterstyle{lucknerto} %% enable

%% Pagestyle 
\makepagestyle{luckner}%
\makeevenhead{luckner}{}{\small{{\MakeUppercase{book title}}}}{} 
\makeoddhead{luckner}{}{\small{{\MakeUppercase{\leftmark}}}}{}
\makeevenfoot{luckner}{\large{\thepage}}{}{}
\makeoddfoot{luckner}{}{}{\large{\thepage}}
\pagestyle{luckner} %% enable

\begin{document}
\chapter{Foobar}
\lipsum[1-20]
\end{document}

在此处输入图片描述

使用 Mikodacs 字体的输出:

在此处输入图片描述

相关内容