我使用 dictum 命令在序言中为每个章节添加简短的引文。现在,我想使用等宽字体:
\setkomafont{dictumtext}{\ttfamily\small}
\setkomafont{dictumauthor}{\ttfamily\small}
我是否可以以某种方式定义仅针对格言环境来改变单词间距?
我找到了这个:
\usepackage{everysel}
\renewcommand*\familydefault{\ttdefault}
\EverySelectfont{%
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
}
但是它会全局改变间距,此外还会将默认字体设置为 \ttdefault
如果我无法一次性为所有格言环境进行设置,那么我每次都可以在本地进行更改吗?
以下是 MWE:
\documentclass[
12pt,
pagesize,
a4paper,
twoside,
openright,
parskip=half,
BCOR=10mm,
DIV=14,
]{scrreprt}
\usepackage{newtxtext,newtxmath}
\usepackage[scaled=.86]{helvet}
\renewcommand*{\ttdefault}{lmtt}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman,english]{babel,varioref}
\usepackage[autostyle,english=american]{csquotes}
\setkomafont{dictumtext}{\ttfamily\small}
\setkomafont{dictumauthor}{\ttfamily\small}
\renewcommand*\dictumwidth{\textwidth}
\renewcommand*\dictumauthorformat[1]{-- #1}
\renewcommand*\dictumrule{}
\usepackage{blindtext}
\begin{document}
\setchapterpreamble[uc]{%
\dictum[\textsc{Lewis Carroll}, \textit{Alice in Wonderland}]{
\enquote{Begin at the beginning}, the King said, gravely, \enquote{and go on till you come to an end; then stop.}}}
\chapter{First chapter}
\blindtext
\end{document}
答案1
\documentclass{scrartcl}
\begin{document}
\dictum[author]{one two three four five }
\setkomafont{dictumtext}{\ttfamily\small}
\dictum[author]{one two three four five }
\setkomafont{dictumtext}{\ttfamily\small\setlength\spaceskip{1cm}}
\dictum[author]{one two three four five }
\end{document}
如果设置了\spaceskip
(或\xspaceskip
句末空格),那么它会覆盖字体中设置的字间间距。这是一个 TeX 原语,因此适用于任何上下文,而不仅仅是\dictum
。