我想更改颜色框中的字体,即章节号的字体,例如使用 \changefont{phv}{b}{n},但不幸的是,当我添加此命令时,颜色框的大小也会改变。有没有办法防止这种情况发生?
\documentclass[ fontsize=12pt,
a4paper,
numbers=noenddot,
headings=big]
{scrreprt}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\newcommand{\changefont}[3]{
\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont}
\usepackage{color}
%\usepackage{blindtext}
\usepackage[minionint,mathlf]{MinionPro}
\renewcommand{\sfdefault}{Myriad-LF}
% Define own Chapter style
% Pretty chapter pages
%------------------------------------------
\usepackage{soul}
\usepackage{pdfpages}
\usepackage{etoolbox}
\makeatletter
\newsavebox{\feline@chapter}
\newcommand\feline@chapter@marker[1][4cm]{%
\sbox\feline@chapter{%
\resizebox{!}{#1}{\fboxsep=0pt%
\colorbox{red}{\color{black}\bfseries\sffamily\thechapter}% %--> \changefont{phv}{b}{n}
}}%
\rotatebox{90}{%
\resizebox{%
\heightof{\usebox{\feline@chapter}}+\depthof{\usebox{\feline@chapter}}}%
{!}{\scshape\so\@chapapp}}\hspace{.4mm}%
\raisebox{\depthof{\usebox{\feline@chapter}}}{\usebox{\feline@chapter}}%
}
\newcommand\feline@chm[1][4cm]{%
\sbox\feline@chapter{\feline@chapter@marker[#1]}%
\makebox[0pt][l]{% aka \rlap
\makebox[1.07cm][r]{\usebox\feline@chapter}%
}}
\renewcommand*{\chapterformat}{%
\hspace{\leftmargin} \feline@chm[2.5cm] % Height of the colored box
\hspace{1.0cm}
}
\patchcmd{\@@makechapterhead}
{\size@chapter{#1}}
{\size@chapter{\parbox[b]{\dimexpr\textwidth-2.8cm\relax}{\raggedright#1}}}
{}
{}
\makeatother
%------------------------------------------
\begin{document}
\chapter{Lorem ipsum dolor sit amet, consectetuer adipiscing elit}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
答案1
由于MinionPro
软件包的原因,我在编译您的文档时遇到了一些问题。
但是,您的问题是由 里面的空格引起的\changefont
。对我来说,\changefont{phv}{b}{n}
用替换 有效:\fontfamily{phv}\bfseries
...
\colorbox{red}{\color{black}\fontfamily{phv}\bfseries\thechapter}%
...
或者,定义\changefont
不带空格的宏:
...
\newcommand{\changefont}[3]{\fontfamily{#1}\fontseries{#2}\fontshape{#3}\selectfont}
...
\colorbox{red}{\color{black}\changefont{phv}{b}{n}\thechapter}
...