我如何“假装” LaTeX 中的倾斜文本?

发布于 2024-08-02 12:35:53 字数 334 浏览 2 评论 0原文

我使用的字体在 LaTeX 中没有倾斜/倾斜变体(注意:不是斜体),并且我希望在某些地方有倾斜的文本。

有没有一种简单的方法可以倾斜文本而无需生成全新的字体文件等?

一个建议的解决方案是:

\renewcommand{\textsl}[1]{\tikz[baseline=(X.base)] \node[xslant=0.2231153] (X) {#1};}

这对于一两个单词来说效果很好,但是 tikz 节点不会跨行,因此对于定理环境来说,它是不够的。

显然,快速而肮脏的方法不会提供特殊的字偶距或间距,但我并不担心这一点。然而,13 度的剪切/倾斜是理想的。

A font I am using does not have the slanted/oblique variant to it in LaTeX (NB: not italics), and I would like to have slanted text in places.

Is there an easy way to slant text without having to generate entirely new font files and such?

One suggested solution was to do:

\renewcommand{\textsl}[1]{\tikz[baseline=(X.base)] \node[xslant=0.2231153] (X) {#1};}

This works well for one or two words, but tikz nodes don't break across lines, so it's not adequate, for, say, a theorem environment.

Obviously, a quick-and-dirty method will not give exceptional kerning or spacing, but I am not concerned about that. However, a 13 degree shear/slant would be desirable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

帥小哥 2024-08-09 12:35:53

您可以在 XeLaTeX 中轻松完成此操作:

\usepackage{fontspec}
...
\fontspec[ItalicFont=*,ItalicFeatures=FakeSlant]{Minion Pro}

但是,如果有任何机会您可以获得

更新:为什么不受欢迎?因为字体轮廓不是设计来扭曲的!除了双向线性缩放之外的任何类型的变换都会改变字母的内/外曲线之间的关系,这实际上违背了字体设计者的意愿。

如果您想用与罗马字体不同的字体突出显示某些内容并且不使用斜体,请尝试完全不同的字体,例如协调无衬线字体。

You can do this easily in XeLaTeX:

\usepackage{fontspec}
...
\fontspec[ItalicFont=*,ItalicFeatures=FakeSlant]{Minion Pro}

Highly undesirable, however, if there's any chance you can get a real italic.

Update: why undesirable? Because font outlines are not designed to be distorted! Any sort of transformation besides linear scaling in both directions will change the relationship between the inner/outer curves of the letters, effectively going against the wishes of the font designer.

If you want to highlight something in a different font than the roman and not use italic, try something completely different like a harmonising sans serif, for example.

逆光下的微笑 2024-08-09 12:35:53

使用有斜体的字体。除非您从事营销工作,否则标准字体是最好的。

Use a font that does have italics. Standard fonts are best unless you're in marketing.

往事随风而去 2024-08-09 12:35:53

我使用 LuaLaTeX,但以下内容也应该适用于 XeLaTeX。根据我的经验,LuaLaTeX 与旧的 LaTeX 完全向后兼容,而且只是稍微慢了一点。制作新的、聪明的宏是轻而易举的事。无论如何,劝说已经足够了。

这几乎是直接从我的一份文档中提取的。是的,其中有些是黑客式的,但它很好地满足了我的需求——而且结果也相当可观。

\usepackage{relsize} % For \texttt definition below
\usepackage{fontspec}

\setmainfont% Minion Pro, not redistributable?
[Ligatures=TeX,
SlantedFont=*,
SlantedFeatures={FakeSlant=0.2},
BoldSlantedFont=* Bold,
BoldSlantedFeatures={FakeSlant=0.2}
]{Minion Pro}

\setsansfont% Linux Biolinum O % SIL Open Font License
[Ligatures=TeX,
Extension=.otf,
BoldFont=fxbb,
ItalicFont=fxbri,
BoldItalicFont=fxbri,
BoldItalicFeatures={FakeBold=1.5}, % Note: This is not currently working in LuaTeX!
SlantedFont=fxbro,
BoldSlantedFont=fxbbo
]{fxbr}

\setmonofont[Ligatures=TeX]{DejaVu Sans Mono} % "Free License" No General Restictions
\makeatletter
\let\old@texttt\texttt
\renewcommand{\texttt}[1]{{\smaller\old@texttt{#1}}}
\makeatother

I use LuaLaTeX, but the following should also work with XeLaTeX. LuaLaTeX, from my experience, is fully backward compatible with good old LaTeX, and it's only marginally slower. And making new, clever macros is a breeze. Anyhow, enough proselytizing.

This is pulled almost directly from one of my documents. Some of it is hackish, yes, but it suits my needs well - and the results are quite respectable.

\usepackage{relsize} % For \texttt definition below
\usepackage{fontspec}

\setmainfont% Minion Pro, not redistributable?
[Ligatures=TeX,
SlantedFont=*,
SlantedFeatures={FakeSlant=0.2},
BoldSlantedFont=* Bold,
BoldSlantedFeatures={FakeSlant=0.2}
]{Minion Pro}

\setsansfont% Linux Biolinum O % SIL Open Font License
[Ligatures=TeX,
Extension=.otf,
BoldFont=fxbb,
ItalicFont=fxbri,
BoldItalicFont=fxbri,
BoldItalicFeatures={FakeBold=1.5}, % Note: This is not currently working in LuaTeX!
SlantedFont=fxbro,
BoldSlantedFont=fxbbo
]{fxbr}

\setmonofont[Ligatures=TeX]{DejaVu Sans Mono} % "Free License" No General Restictions
\makeatletter
\let\old@texttt\texttt
\renewcommand{\texttt}[1]{{\smaller\old@texttt{#1}}}
\makeatother
岁月静好 2024-08-09 12:35:53

这里有一些用于剪切的宏,但我想这也不是您想要的。

\usepackage{graphicx}

%\hshearbox{vertical_prescale_times_shearfactor}{one_divide_by_shearfactor}{content}
% an initial vertical downscale is often necessary for a 3d projection
\newcommand{\hshearbox}[3]{\scalebox{0.866025}[#2]{\rotatebox{210}%
{\scalebox{1.73205}[-0.57735]{\rotatebox{60}{\scalebox{-1.1547}[#1]{#3}}}}}}

%\vshearbox{horizontal_prescale_times_shearfactor}{one_divide_by_shearfactor}{content}
% an initial horizontal downscale is often necessary for a 3d projection
\newcommand{\vshearbox}[3]{\scalebox{#2}[0.866025]{\rotatebox{210}%
{\scalebox{-0.57735}[1.73205]{\rotatebox{60}{\scalebox{#1}[-1.1547]{#3}}}}}}

Here are some macros for shearing, but that will not be what you want either, I guess.

\usepackage{graphicx}

%\hshearbox{vertical_prescale_times_shearfactor}{one_divide_by_shearfactor}{content}
% an initial vertical downscale is often necessary for a 3d projection
\newcommand{\hshearbox}[3]{\scalebox{0.866025}[#2]{\rotatebox{210}%
{\scalebox{1.73205}[-0.57735]{\rotatebox{60}{\scalebox{-1.1547}[#1]{#3}}}}}}

%\vshearbox{horizontal_prescale_times_shearfactor}{one_divide_by_shearfactor}{content}
% an initial horizontal downscale is often necessary for a 3d projection
\newcommand{\vshearbox}[3]{\scalebox{#2}[0.866025]{\rotatebox{210}%
{\scalebox{-0.57735}[1.73205]{\rotatebox{60}{\scalebox{#1}[-1.1547]{#3}}}}}}
人疚 2024-08-09 12:35:53

上面提到的 XeLaTeX/fontspec 答案不知何故对我不起作用,所以我想出了这个:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Linux Libertine O}

\newcommand{\slsc}[1]{\fontspec[SmallCapsFeatures={FakeSlant=0.6}]{Linux Libertine O}\textsc{#1}\fontspec[]{Linux Libertine O}}

\begin{document}

    normaltext

    \textsc{textsc}

    \slsc{textslsc} % this will produce slanted small caps

\end{document}

The XeLaTeX/fontspec answer mentioned above somehow wouldn't work for me, so I came up with this:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Linux Libertine O}

\newcommand{\slsc}[1]{\fontspec[SmallCapsFeatures={FakeSlant=0.6}]{Linux Libertine O}\textsc{#1}\fontspec[]{Linux Libertine O}}

\begin{document}

    normaltext

    \textsc{textsc}

    \slsc{textslsc} % this will produce slanted small caps

\end{document}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文