![随意更改字体或字体特征](https://linux22.com/image/315267/%E9%9A%8F%E6%84%8F%E6%9B%B4%E6%94%B9%E5%AD%97%E4%BD%93%E6%88%96%E5%AD%97%E4%BD%93%E7%89%B9%E5%BE%81.png)
建立了文档平台如下:
\documentclass[10pt,b5paper,twoside]{report}
%--------------------------
%--- Packages required
%--------------------------
\usepackage{microtype}
\usepackage{lettrine}
\usepackage{fontspec}
\usepackage{fourier-orns, multido}
\usepackage{graphicx}
\usepackage{tabularx, booktabs}
\usepackage{enumitem}
\usepackage{titleps}
\usepackage[textwidth=110mm, textheight=180mm, marginratio={4:6,5:7},nofoot, nomarginpar]{geometry}
\usepackage{polyglossia}
\usepackage{setspace}
%--------------------------
%--- Set commands
%--------------------------
\defaultfontfeatures{Numbers = {OldStyle,Proportional},Ligatures = Rare, Style = Historic,
StylisticSet={1,5},WordSpace = 1.2}%
\renewpagestyle{plain} {%
\sethead{}{[\enspace\thepage\enspace]}{}
}%
\pagestyle{plain}
\setmainlanguage{english}
%---------------------------------------------------------
%--- Fonts used: IM FELL DW Pica Font Family
%--- http://www.1001fonts.com/im-fell-dw-pica-font.html
%---------------------------------------------------------
\setmainfont{IMFePisc29P.ttf}
%------------------------------
%--- Beginning of the document
%------------------------------
\begin{document}
\newgeometry{textwidth=89mm, textheight =158mm, marginratio={4:6,5:7},nofoot}
\noindent\renewcommand\arraystretch{2}
\hskip-0.2em\multido{\n=1+1}{14}{\decoone\decosix}\decoone
\noindent\begin{tabularx}{\linewidth}{@{} >{\centering\LARGE\addfontfeature{LetterSpace=15.0}
\arraybackslash}X@{}}
\textsc{r e s u l t} \\
\textsc{\normalsize of the} \\
\itshape CONVENTION, \&c. \\
\bottomrule
\end{tabularx}
\vskip4ex
%---------------------------------------------
%--- Needs to be italicized and set to 12pt
%---------------------------------------------
\setlength\leftskip{1em}{\itshape\hskip-2.3em
In Convention of Delegates from the several towns of Lynn, Salem, Danvers, Wenham,
Manchester, Glou\-cester, Ipswich, Newbury-Port, Salisbury, Methuen, Boxford \& Topsfield,
holden by adjourment at Ipswich, on the twenty-ninth day of April, one thousand seven
hundred \& seventy eight.}
%---------------------------------------------
%--- Needs to be bold, set to 12pt, left justified
%---------------------------------------------
\vspace{5mm} %added to make space
\large Peter Coffin Esq ; in the Chair.
%------------------------------------------------------
%--- Needs to be set to 10pt after large first letter
%------------------------------------------------------
\vspace{5mm} %added to make space
\setlength\leftskip{2mm}
\lettrine[lines=4,slope=0.6em,findent=0.6em,nindent=0em]{T}{HE} Constitution and form of Government framed
by the Convention of this State, was read paragraph by paragraph, and after debate, the following
votes were passed.
\end{document}
如何实现以下目标:
- 使用列出的斜体字体将指示的段落斜体化,并设置该段落的字体大小
- 在一行中左对齐(Peter Coffin Esq 行)
- “随机”地在本地改变字体、大小、形状(通常针对文档的任何部分)?
提前感谢您的帮助。
答案1
fontspec
手册第 6 页内容如下:
文件名选择的字体必须明确包含粗体和斜体变体。
\setmainfont{texgyrepagella-regular.otf}[ BoldFont = texgyrepagella-bold.otf , ItalicFont = texgyrepagella-italic.otf , BoldItalicFont = texgyrepagella-bolditalic.otf ]
在这种情况下,例如:
\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}
This is 10pt upright.
\textit{This is 10pt italics.}
\textsc{This is 10pt small-caps.}
{\itshape\large This is 12pt italics.
\scshape This is 12pt small-caps.
\upshape This is 12pt upright.
}
This is 10pt upright.
\kant[1]
{\itshape \kant[2]}
{\small\itshape \kant[3]}
{\large \kant[4]}
\end{document}
生产
例如,您可以使用\newfontfamily\commandname{...}
它来定义要用于特殊效果的字体。这可以像文本的主文档字体一样定义。或者它可以是装饰字体或专业字体。
例如:
\newfontfamily\imflowers{IMFeFlow1.ttf}
请允许我说
{\imflowers ABCDEFGHIJKLMNOPQRSTUVWXYZ abc}
如果我想用一些印刷装饰品来说明文本:
[如果字体是为系统安装的,不需要通过文件名调用,那么这一切都会变得更容易。事实上,我仍然觉得在 pdfLaTeX 中更容易!至少在那里,如果我想使用它,我确实有完全的控制权。]
随意更改字体或字体特征
要更改文档任意部分的字体形状,可以使用
\itshape
所有文字,直至另行通知都将以斜体显示。\scshape
除非另行通知,所有文字均将采用小写字母。\normalfont
返回默认字体形状(和粗细)。
例如:
\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}
\itshape \kant[1]
\scshape \kant[2]
\normalfont \kant[3]
\end{document}
您还可以使用花括号来限制形状命令的范围,如上面的示例所示。
Regular shape.
{\itshape Italics here.
More italics.
Yet more italics.}
Regular shape again.
类似地,标准尺寸命令的工作方式相同,也可能通过使用花括号或类似方法分组来进行限制。
\documentclass[a4paper]{article}
\usepackage{fontspec,kantlipsum}
% font features set according to the copies of the fonts I have
\setmainfont{IMFePIrm29P.ttf}[% fontspec complains about the features not being available for sc and trying to deactivate them makes it complain again about a lack of the deactivated-feature - pah! this thing is noisy!
ItalicFont = IMFePIit29P.ttf,
SmallCapsFont = IMFePIsc29P.ttf,
StylisticSet=1,
WordSpace = 1.2,
Ligatures = Rare,
Style = Historic,
]
\begin{document}
\tiny As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\scriptsize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\footnotesize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\small As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\normalsize As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\large As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\Large As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\LARGE As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\Huge As is own in the writings of Aristotle, the things in themselves (and it remains a mystery why this is the case) are a representation of time.
\end{document}
当然,您也可以使用其他fontspec
命令来调整字体启用的功能,例如关闭Rare
连字。但是,您可能不希望这样做,因为这会使排版不一致。(当然,除非您正在撰写此类排版功能,这将是另一回事,此类插图可能会很有用。)