我正在使用包graphicsx
、fontspec
和microtype
。
我已将可缩放矢量图形.svg
图像导入我的文档中,然后使用 Inkscape进行\includegraphics[height=\heightof{0123456789}]{myimage.pdf}
转换。我已缩放图像,使其高度等于单个数字的高度。我还通过使用了表格和衬线数字。因此,我导入的图像看起来像一个文本内符号,其大小与大写字母大致相同。当然,这很好,因为我可以导入或多或少可以在句子和段落中使用的图像。myimage.svg
myimage.pdf
Numbers={Lining,Tabular}
.svg
但是,我发现microtype
的font expansion
功能只会拉伸/收缩字符字形,而不会拉伸/收缩字符图形。我尝试通过命令的宽度参数为字符图形添加拉伸或收缩\includegraphics
,但它不允许拉伸或收缩宽度(width=
不会接受参数中的加号,我尝试为宽度添加拉伸但没有成功。见下文)。我在上述软件包中找不到可以解决此问题的任何内容。
我尝试通过以下方法将拉伸/收缩添加到字符图形宽度。拉伸/收缩其他文本时,无法拉伸/收缩字符图形。请注意,我的 MWE 不提供图形svg
。
\documentclass{article}
\usepackage{calc}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Source Serif 4}[%Available for free on Google Fonts.
Kerning=On,Numbers={Lining,Tabular}
]
\usepackage[%
protrusion=true%character protrusion, default=true
,factor=1000%units: 1/1000 of character width, default=1000
,expansion=true%font expansion, default=true
,stretch=250%units: thousandths of an em, default=20
]{microtype}%
\newcommand{\myimage}{%
\begingroup%
\sbox0{0123456789}%
%\includegraphics[height={\ht0}]{myimage.pdf}%
\includegraphics[height={\ht0},width={0.5762\ht0 plus 0.1441\ht0 minus 0.1441\ht0}]{myimage.pdf}%
\endgroup%0.5762 is the width/height ratio, the 0.1441 stretch and shrink numbers are exaggerated, but they don't work regardless
}
\usepackage[indent=0pt]{parskip}
\begin{document}
The following line is stretched, except for the character-graphic.\\
\myimage{}%
It fails to stretch/shrink the character-graphic while stretch/shrink.\\
The following line is shrunk, except for the character-graphic.:\\
\myimage{}%
It fails to stretch/shrink the character-graphic while stretching/shrinking the other text.
\par
\microtypesetup{expansion=false}
For comparison, I've removed font expansion in the following line:\\
\myimage{}%
It fails to stretch/shrink the character-graphic while stretching/shrinking the other text.\\
\end{document}