梅威瑟:
% main.tex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[urw-garamond]{mathdesign}
% \usepackage{fontenc} T1,T2A?
% \usepackage{fontspec} ?
\usepackage[russian,english]{babel}
\begin{document}
“Hello” is the same as “Привет”.
\end{document}
如何构建:
lualatex -synctex=1 -interaction=nonstopmode -file-line-error -recorder main.tex
不记录\usepackage[russian,english]{babel}
:
Latexmk: This is Latexmk, John Collins, 26 Dec. 2019, version: 4.67.
Latexmk: All targets () are up-to-date
输出:
登录方式\usepackage[russian,english]{babel}
:
Latexmk: This is Latexmk, John Collins, 26 Dec. 2019, version: 4.67.
Rule 'lualatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.tex'
'main.tex'
------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -recorder -output-directory="/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions" "/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.tex"'
------------
Latexmk: applying rule 'lualatex'...
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-02-25> (/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/inputenc.sty
Package inputenc Warning: inputenc package ignored with utf8 based engines.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mathdesign.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/mdugm.cfg) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/mdugm.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdfont.def) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdsffont.def
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 53.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 56.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 59.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 79.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 102.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 105.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 108.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 128.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 259.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 262.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 265.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 268.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 313.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 316.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 319.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 322.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdttfont.def) (/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
LaTeX Font Warning: Font shape `TU/mdugm/m/n' undefined
(Font) using `TU/lmr/m/n' instead on input line 186.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/t1mdugm.fd))) (/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def) (/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.aux
Package babel Warning: Unknown language `russian'. Very likely you
(babel) requested it in a previous run. Expect some
(babel) wrong results in this run, which should vanish
(babel) in the next one. Reported on input line 4.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdacmr.fd) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdbcmr.fd) [1{/home/timfayz/.texlive2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.aux)
LaTeX Font Warning: Some font shapes were not available, defaults substituted.
)
(see the transcript file for additional information)
411 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 49 glue_spec, 4 attribute_list, 1 write nodes
avail lists: 2:15,3:2,4:1,5:21,6:1,7:36,9:7
{/usr/local/texlive/2019/texmf-dist/fonts/enc/dvips/ly1/texnansi.enc}</home/timfayz/.texmf/fonts/type1/urw/garamond/ugmr8a.pfb>
Output written on main.pdf (1 page, 13243 bytes).
SyncTeX written on main.synctex.gz.
Transcript written on main.log.
Latexmk: Log file says output to 'main.pdf'
Rule 'lualatex': File changes, etc:
Changed files, or newly in use since previous run(s):
'/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.aux'
'main.aux'
------------
Run number 2 of rule 'lualatex'
------------
------------
Running 'lualatex -synctex=1 -interaction=nonstopmode -file-line-error -recorder -output-directory="/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions" "/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.tex"'
------------
=== TeX engine is 'LuaTeX'
Latexmk: applying rule 'lualatex'...
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
restricted system commands enabled.
(/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-02-25> (/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo)) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/inputenc.sty
Package inputenc Warning: inputenc package ignored with utf8 based engines.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mathdesign.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ifthen.sty) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/mdugm.cfg) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/mdugm.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdfont.def) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdsffont.def
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 53.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 56.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 59.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 79.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 102.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 105.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 108.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 128.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 259.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 262.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 265.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 268.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 313.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 316.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 319.
LaTeX Warning: Font shape declaration has incorrect series value `mc'.
It should not contain an `m'! Please correct it.
Found on input line 322.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdttfont.def) (/usr/local/texlive/2019/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/local/texlive/2019/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
LaTeX Font Warning: Font shape `TU/mdugm/m/n' undefined
(Font) using `TU/lmr/m/n' instead on input line 186.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdugm/t1mdugm.fd))) (/usr/local/texlive/2019/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.def) (/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.aux) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdacmr.fd) (/usr/local/texlive/2019/texmf-dist/tex/latex/mathdesign/mdbcmr.fd) [1{/home/timfayz/.texlive2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (/home/timfayz/Dropbox/PhD/TeX/RandomDefinitions/main.aux)
LaTeX Font Warning: Some font shapes were not available, defaults substituted.
)
(see the transcript file for additional information)
411 words of node memory still in use:
3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 4 attribute, 49 glue_spec, 4 attribute_list, 1 write nodes
avail lists: 2:15,3:2,4:1,5:21,6:1,7:36,9:7
{/usr/local/texlive/2019/texmf-dist/fonts/enc/dvips/ly1/texnansi.enc}</home/timfayz/.texmf/fonts/type1/urw/garamond/ugmr8a.pfb>
Output written on main.pdf (1 page, 13243 bytes).
SyncTeX written on main.synctex.gz.
Transcript written on main.log.
Latexmk: Log file says output to 'main.pdf'
Latexmk: Summary of warnings from last run of (pdf)latex:
=====Latex reported missing or unavailable character(s).
=====See log file for details.
=== TeX engine is 'LuaTeX'
Latexmk: All targets () are up-to-date
输出:
以下是我想要实现的目标:
- 我想使用 URW Garamond 及其 mathdesign 版本来输入数学
- 我希望有西里尔字母字形支持(当然,如果 URW Garamond 支持的话,如果不支持 - 则仅为俄语字符范围设置另一种字体)
- 我希望能够在文本和数学模式下使用 UTF-8 符号
- 我想知道如何列出系统中可用的字体(包括它们的常规名称,如下面的示例中所示,以及文件名)。或者更好的是,不仅列出名称,还要检查字体是否支持俄语字形。
话虽如此,我不知道如何将所有这些碎片粘合在一起 :(。目前我所知道的是:
- 我需要以正确的顺序混合
inputenc
、、、、以及正确的选项fontspec
fontenc
mathdesign
babel
- 阅读日志并没有给我任何有用的信息。我在俄罗斯网站上进行了很多尝试和阅读,但什么也没得到。似乎人们只是奇迹般地让它工作了。
- 我不知道我是否还需要
\usepackage[utf8]{inputenc}
序言。我需要吗(2020 年)?因为我最近收到了以下内容Package inputenc Error: inputenc is not designed for xetex or luatex.
(我不记得当时的情况,但我把它留到最坏的时候) - 好像
babel
后面重新定义了字体,这让我很困惑。我觉得它没有触及字体设置,我们应该使用fontspec
它。 - 由于上述原因,我不知道如何正确管理所有这些特殊的字体设置。我们有很多方法可以做同样的事情。下面是一些显式或隐式影响最终字体样式的命令:
% Method 1
\usepackage{fontspec}
\setmainfont{EB Garamond}
\setsansfont{CMU Sans Serif}
\setmonofont{...}
% Method 2
\usepackage{unicode-math}
\setmathfont{texgyrepagella-math.otf}
% Method 3
\usepackage{ebgaramond} % just an example at hand, I encountered other packages that redefine typefaces as well
% Method 4
\babelfont{rm}{DejaVu Serif} % ?
环境:
$ lualatex -v
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
$ tlmgr version
tlmgr revision 53842 (2020-02-19 08:28:40 +0100)
tlmgr using installation: /usr/local/texlive/2019
$ latex -v
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019)
kpathsea version 6.3.1
$ latexmk -v
Latexmk, John Collins, 26 Dec. 2019. Version 4.67
我明确安装的软件包(仅查看未注释的行):
tlmgr update --self
tlmgr install \
collection-basic \
# luatex \
collection-latex \
collection-latexrecommended \
# fontspec \
collection-luatex \
# luaotfload \
# lualatex-math \
collection-fontsrecommended \
# cm-super \ # cyrillic support (T1 encoding)
# collection-binextra \
latexmk \
texliveonfly \ # resolve deps automagically
# collection-pictures \
pgfplots \
# collection-latexextra \
needspace \
mdframed \
multirow \ # to create cells spanning multiple rows
# collection-bibtexextra \
biblatex biber \ # modern bibliography engine + backend
# collection-fontsextra \
ebgaramond \ # favorite serif font
mathdesign \ # favorite math + normal text font
ly1 \ # resolve missing texnansi.enc
# collection-langcyrillic \
babel-russian \ # russian support
urw-garamond
按照建议手动安装这里
答案1
这是一个示例,可帮助您开始了解 Unicode 轨迹。
我会在接下来的几天和几周内尽力补充内容。所有问题的答案几乎就像一套迷你教程。
从一般文本开始:
字体=Noto Serif;语言=Tatar;文本来源=Wikipedia;编译器=xelatex(或 lualatex);文本主题=太阳系;连字符模式=俄语,通过 babel。
练习:尝试不带 的例子babel
,看看连字符会发生什么变化。
\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\usepackage[russian]{babel}%hyphenation
\begin{document}
“Hello” is the same as “Привет”.
\bigskip
tt Wikipedia
\section*{Кояш системасы}
\textbf{Кояш системасы} — Кояш йолдызы һәм аның тирәсендә әйләнә торган табигый галәми объектлар белән планеталар системасы.
Кояш системасының Кояштан тыш объектларының төп массасы сигез аерым планетада була. Алар эклиптика яссылыкта түгәрәккә якын орбиталар буенча хәрәкәт итәләр. Дүрт кечерәк эчке планета: Меркурий, Чулпан, Җир һәм Марс (җирсыман планеталар) гомумән силикатлардан һәм металлардан гыйбарәт була. Дүрт зуррак тышкы планета: Юпитер, Сатурн, Уран һәм Нептун (зур газлы планеталар) төп өлешендә водородтан һәм гелийдан гыйбарәт була һәм җирсыман планеталардан күпкә авыррак.
\end{document}
如何查找字体
该fc-list
实用程序很有用:fc-list :lang=zh-cn
查找支持中文的字体(如何列出我已安装的所有中文字体?(Ubuntu,TexLive))。
一个实验:在我的系统 (Windows) 上,执行fc-list :lang=tt-tt
,查找支持 Tatar 的字体,生成一个包含PT Sans
字体的列表。在 MWE 中使用该字体作为测试用例会产生以下结果:
实际上,据我所知,从字形覆盖的角度来看,它看起来还不错(我还没有学过鞑靼语)。
除此之外,还有其他方法:使用字体编辑器或字符映射查看字体本身;使用 xelatex/fontspec 代码列出字体特征(本网站上的问题);使用 BabelPad 等免费应用程序来检查字体对 Unicode 块的覆盖范围,或 Unicode 块对字体的覆盖范围;等等。
答案2
其中一些软件包适用于不同的引擎,您无法将它们一起使用。在 LuaLaTeX 或 XeLaTeX 中,您只能使用 Unicode 字体。
您可以通过 加载 Garamond 字体系列unicode-math
,但已经有一个软件包可以为您完成此操作,fontsetup
。如果您只需要俄语短语,它可能就足够了:
\documentclass{article}
\tracinglostchars=3 % Make it an error if a character is missing from the current font.
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX.
\usepackage{mathtools}
\usepackage[russian,english]{babel}
\usepackage[ebgaramond]{fontsetup}
\newcommand\iu{\i} % The imaginary unit.
\newcommand\diff{\mathop{}\symup{d}} % The differential operator.
\begin{document}
Pafnuty Chebyshev (Пафну́тий Чебышёв) proved that the differential equation
\begin{gather}
\left(1 - x^2\right) \frac{\diff^2 y}{\diff x^2} +
\frac{\diff y}{\diff x} +
\alpha^2 y
= 0 \\
\intertext{has the solution}
\begin{aligned}
y = &c_1 \cosh \left[ \alpha \ln \left( x + \sqrt{x^2 - 1} \right)\right] + \\
&\iu c_2 \sinh \left[ \alpha \ln \left(x+ \sqrt{x^2 - 1} \right)\right]
\end{aligned}
\end{gather}
\end{document}
如果您想要包含带有正确连字符的完整俄语句子,您可以在 LuaLaTeX 中使用这个模板,它可以检测您输入的语言并相应地设置字体和连字符规则:
\documentclass{article}
\tracinglostchars=3 % Make it an error if a character is missing from the current font.
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX.
\usepackage{mathtools}
\usepackage[english]{babel}
\usepackage{unicode-math}
\usepackage{microtype}
\babelprovide[import, onchar=fonts ids]{russian}
\babelfont{rm}
{EBGaramond}
\setmathfont{Garamond-Math}
\newcommand\iu{\i} % The imaginary unit.
\newcommand\diff{\mathop{}\symup{d}} % The differential operator.
\begin{document}
Pafnuty Chebyshev (Пафну́тий Чебышёв) proved that the differential equation
\begin{gather}
\left(1 - x^2\right) \frac{\diff^2 y}{\diff x^2} +
\frac{\diff y}{\diff x} +
\alpha^2 y
= 0 \\
\intertext{has the solution}
\begin{aligned}
y = &c_1 \cosh \left[ \alpha \ln \left( x + \sqrt{x^2 - 1} \right)\right] + \\
&\iu c_2 \sinh \left[ \alpha \ln \left(x+ \sqrt{x^2 - 1} \right)\right]
\end{aligned}
\end{gather}
Пафну́тий Льво́вич Чебышёв—русский математик и механик,
основоположникпетербургской математической школы, академик Петербургской
академии наук (адъюнкт с 1853 года, экстраординарный академик с 1859 года)
и ещё 24 академий мира.
\end{document}
如果您的出版商在 2021 年或以后仍然强迫您在 PDFLaTeX 中使用 8 位字体,则此模板应该可以工作:这将加载支持西里尔文的 Garamond Libre 的免费版本作为文本字体而不是数学字体mathdesign
。
\documentclass{article}
\tracinglostchars=3 % Make it an error if a character is missing from the current font.
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc} % The default since 2018.
\usepackage[paperwidth=10cm]{geometry} % Format the MWE for TeX.SX.
\usepackage{mathtools}
\usepackage[russian,english]{babel}
\usepackage{microtype}
\usepackage[garamond]{mathdesign}
\usepackage{garamondlibre}
\newcommand\iu{\textit{\i}} % The imaginary unit.
\newcommand\diff{\mathop{}\mathrm{d}} % The differential operator.
\begin{document}
Pafnuty Chebyshev (\foreignlanguage{russian}{Пафн\'{у}тий Чебышёв}) proved that
the differential equation
\begin{gather}
\left(1 - x^2\right) \frac{\diff^2 y}{\diff x^2} +
\frac{\diff y}{\diff x} +
\alpha^2 y
= 0 \\
\intertext{has the solution}
\begin{aligned}
y = &c_1 \cosh \left[ \alpha \ln \left( x + \sqrt{x^2 - 1} \right)\right] + \\
&\iu c_2 \sinh \left[ \alpha \ln \left(x+ \sqrt{x^2 - 1} \right)\right]
\end{aligned}
\end{gather}
\begin{otherlanguage}{russian}
Пафн\'{у}тий Льв\'{о}вич Чебышёв—русский математик и механик,
основоположникпетербургской математической школы, академик Петербургской
академии наук (адъюнкт с 1853 года, экстраординарный академик с 1859 года)
и ещё 24 академий мира.
\end{otherlanguage}
\end{document}
这里需要一些解决方法。首先,PDFLaTeX 无法自动检测您使用的语言,因此此版本的文档需要明确标记。其次,PDFLaTeX 无法处理组合重音符号(例如 U+0301),但 Unicode 中没有预组合字母(例如 У́),因此您必须将它们写成类似 的形式\'{У}
。