Debian Codegraph @

texmf-dist/doc/latex/lebhart/README.md

raw
1 <!-- Copyright (C) 2021-2026 by Jinwen XU -->
2
3 # `lebhart` : write you articles in a colorful way
4
5 > **New documentations are still being written. For now, only the core code is included in TeX Live and MiKTeX (old documentations have been removed from the distribution).**
6
7 `lebhart` is a LaTeX class for typesetting articles, which has a colorful design.
8
9 Currently, it has native support to Chinese (simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish typesetting. And it may compile with either XeLaTeX or LuaLaTeX.
10
11 This is part of the `colorist` class series.
12
13 > Package dependencies: [`amsfonts`](https://ctan.org/pkg/amsfonts), [`caption`](https://ctan.org/pkg/caption), [`colorist`](https://ctan.org/pkg/colorist), [`ctex`](https://ctan.org/pkg/ctex), [*`draftwatermark`*](https://ctan.org/pkg/draftwatermark), [`embrac`](https://ctan.org/pkg/embrac), [`float`](https://ctan.org/pkg/float), [`fontspec`](https://ctan.org/pkg/fontspec), [`geometry`](https://ctan.org/pkg/geometry), [`graphicx`](https://ctan.org/pkg/graphicx), [`indentfirst`](https://ctan.org/pkg/indentfirst), [*`kpfonts-otf`*](https://ctan.org/pkg/kpfonts-otf), [*`lua-widow-control`*](https://ctan.org/pkg/lua-widow-control), [*`mathpazo`*](https://ctan.org/pkg/mathpazo), [*`nowidow`*](https://ctan.org/pkg/nowidow), [`parskip`](https://ctan.org/pkg/parskip), [`projlib`](https://ctan.org/pkg/projlib), [`regexpatch`](https://ctan.org/pkg/regexpatch), [`silence`](https://ctan.org/pkg/silence), [`tikz-cd`](https://ctan.org/pkg/tikz-cd), [`unicode-math`](https://ctan.org/pkg/unicode-math), [`wrapfig2`](https://ctan.org/pkg/wrapfig2).
14
15 ## Features
16
17 Compared with usual document classes, it has the following features:
18
19 - Several carefully designed styles.
20 - Native multilingual support: Chinese (simplified and traditional), English, French, German, Italian, Japanese, Portuguese (European and Brazilian), Russian and Spanish.
21 > In particular, for simplified Chinese, traditional Chinese and Japanese, the fonts of the corresponding glyphs can be automatically switched.
22 - Ready-to-use theorem-type environments, with clever referencing supported.
23 - Support both the standard and the AMS writing fashion.
24 - ... and much more...
25
26 ## Required fonts
27
28 The current document class requires the following open-source fonts that are not included in the standard TeX collection:
29
30 - The Source Han font series at [Adobe Fonts](https://github.com/adobe-fonts). More specifically:
31 - Source Han Serif, [go to its Release page](https://github.com/adobe-fonts/source-han-serif/releases).
32 - Source Han Sans, [go to its Release page](https://github.com/adobe-fonts/source-han-sans/releases).
33 - Source Han Mono, [go to its Release page](https://github.com/adobe-fonts/source-han-mono/releases).
34 > It is recommended to download the Super-OTC version, so that the download size would be smaller.
35
36 ## Improvements to the current font configuration
37
38 > The code in this section is rather experimental and may constantly get changed. The author uses these lines of code in his daily documents, but since it involves non-free fonts and/or uses complex Lua patches, the code below cannot be integrated into the published version.
39
40 If you are willing to use LuaLaTeX, then the following aspects may help you further improve the current font configuration.
41
42 - If you have the font `Palatino Linotype` installed, then replacing the default `TeXGyrePagellaX` using the following code gives you slightly better result:
43 ```latex
44 \directlua
45 {
46 fonts.handlers.otf.addfeature
47 {
48 name = "palatino-linotype-fix",
49 type = "kern",
50 data =
51 {
52 ["r"] = { ["ê"] = 120 },
53 ["v"] = { ["ê"] = 180 },
54 ["w"] = { ["ê"] = 180 },
55 ["y"] = { ["ê"] = 180 },
56 },
57 }
58 }
59 \setmainfont{Palatino Linotype}
60 [
61 Numbers = OldStyle ,
62 RawFeature = +palatino-linotype-fix
63 ]
64 ```
65 - If you have the font `Palatino Sans LT Pro` installed, then replacing the default `mathsf` font with this gives more pleasant visual effect:
66 ```latex
67 \setmathsf{Palatino Sans LT Pro}
68 \setmathfont{PalatinoSansLTPro-LightIta}[range=sfit]
69 ```
70 - The default configuration for math fonts has some imperfections. The following code helps to improve it. But for this you need to modify the `.cls` file itself and then maintain your local version of it. Here is how:
71 - First, add this definition at the beginning of the font configuration.
72 ```latex
73 \ExplSyntaxOff
74 % https://tex.stackexchange.com/a/505003
75 \def\mathkern@fix@for@lua
76 {
77 \directlua
78 {
79 local mathkerns = {
80 ["Asana-Math"] = {
81 [0x1D447] = {% T
82 bottomright = {
83 {height=0,kern=-120},
84 },
85 },
86 [0x1D449] = {% V
87 bottomright = {
88 {height=0,kern=-120},
89 },
90 },
91 [0x1D44A] = {% W
92 bottomright = {
93 {height=0,kern=-30},
94 },
95 },
96 [0x1D453] = {% f
97 bottomright = {
98 {height=0,kern=-135},
99 },
100 },
101 [0x1D44F] = {% b
102 topright = {
103 {height=0,kern=75},
104 },
105 },
106 },
107 ["KpMath-Regular"] = {
108 [0x1D6FD] = {% \beta
109 bottomright = {
110 {height=0,kern=30},
111 },
112 },
113 [0x1D6FF] = {% \delta
114 bottomright = {
115 {height=0,kern=30},
116 },
117 },
118 [0x1D702] = {% \eta
119 bottomright = {
120 {height=0,kern=30},
121 },
122 },
123 [0x1D703] = {% \theta
124 bottomright = {
125 {height=0,kern=10},
126 },
127 },
128 [0x1D714] = {% \omega
129 bottomright = {
130 {height=0,kern=30},
131 },
132 },
133 },
134 }
135 local function initmathkern(tfmdata)
136 local values = mathkerns[tfmdata.properties.psname]
137 if not values then return end
138 for cp, value in next, values do
139 local tcp = type(cp)
140 if tcp == 'string' then
141 cp = tfmdata.resources.unicodes[cp]
142 end
143 local char = tfmdata.characters[cp]
144 if char then
145 local mathkern = char.mathkerns
146 if not mathkern then
147 mathkern = {}
148 char.mathkerns = mathkern
149 end
150 for corner, v in next, value do
151 mathkern[corner] = v
152 end
153 end
154 end
155 end
156 fonts.constructors.newfeatures'otf'.register{
157 name = 'mathkern',
158 description = 'Overwrite mathkern values',
159 initializers = {
160 base = initmathkern,
161 },
162 }
163 }
164 }
165 \ExplSyntaxOn
166 ```
167 - Then, just before `\RequirePackage { unicode-math }`, add these lines:
168 ```latex
169 \sys_if_engine_luatex:T
170 {
171 \mathkern@fix@for@lua
172 }
173 ```
174 - Finally, replace `\setmathfont { KpMath-Regular.otf }` with `\setmathfont [ RawFeature = mathkern ] { KpMath-Regular.otf }`, and replace
175 ```latex
176 \setmathfont { texgyrepagella-math.otf }
177 [
178 range = { it / { Latin, latin }, bfit / { Latin, latin }, up / num, bfup / num }
179 ]
180 ```
181 with
182 ```latex
183 \setmathfont [ RawFeature = mathkern ] { Asana-Math.otf }
184 [
185 range = { it / { Latin, latin }, bfit / { Latin, latin }, up / num, bfup / num }
186 ]
187 ```
188
189 # License
190
191 This work is released under the LaTeX Project Public License, v1.3c or later.
192