latex中字体问题的进一步讨论

latex中字体问题的进一步讨论

不仅仅是在latex中,其实在所有的排版问题中,字体都是一个很重要的问题。它是一个设计问题,犹如版面设计,需要考虑不同的配色,考虑不同的装饰。字体问题也有类似的情况,在文档中,文字是版面的主体,可以影响版面的整体呈现,也可以影响局部呈现。

怎么设置好文字,让局部看起来美观舒适,就是颜色搭配一样,这是一个搭配设计问题。设计合适的段落格式,合适的行距,合适的字距,合适的字体,合适字符大小,合适的中英文字体搭配。

字体有字族(通常是中文环境中的字体),字形/系(粗、斜等,通常是中文环境中的字重),字号(字符大小)等问题。不同内容的搭配就是对其作出合适的选择,内容包括,中文,英文,公式,符号等。

设计问题就是一个见仁见智的问题了,不同的人看同一个东西会有不同的美的感受,这里不在这个方面做讨论。而是讲技术上怎么实现这种选择的问题。

字体的设置可以采用latex传统的`\fontencoding`,`\fontfamily`,`\fontseries`
,`\fontshape`,`\fontsize`和`\selectfont`这样的命令来设置。

更简单的方法是利用fontspec宏包,中文字体设置还可以使用ctex宏包的接口。

其中,一般的设置如下
```
%----中文字体
\setCJKmainfont[Path="fonts/",
BoldFont={AdobeHeitiStd-Regular.otf},
ItalicFont=AdobeKaitiStd-Regular.otf]{AdobeSongStd-Light.otf}
\setCJKsansfont[Path="fonts/"]{AdobeHeitiStd-Regular.otf}
\setCJKmonofont[Path="fonts/"]{AdobeFangsongStd-Regular.otf}
\setCJKfamilyfont{zhsong}[Path="fonts/"]{AdobeSongStd-Light.otf}
\setCJKfamilyfont{zhhei}[Path="fonts/"]{AdobeHeitiStd-Regular.otf}
\setCJKfamilyfont{zhkai}[Path="fonts/"]{AdobeKaitiStd-Regular.otf}
\setCJKfamilyfont{zhfs}[Path="fonts/"]{AdobeFangsongStd-Regular.otf}
\setCJKfamilyfont{zhli}[Path="fonts/"]{NotoSansHans-Black.otf}
\setCJKfamilyfont{zhyou}[Path="fonts/"]{NotoSansHans-Thin-Windows.otf}

%----英文字体
\setmainfont{LinLibertine_R.otf}[
Path="fonts/",
BoldFont=LinLibertine_RB.otf,
ItalicFont=LinLibertine_RI.otf,
BoldItalicFont=LinLibertine_RBI.otf,
SlantedFont = LinLibertine_aRL.ttf,
BoldSlantedFont = LinLibertine_aBL.ttf,
SmallCapsFont = LinLibertine_aS.ttf
]
\setsansfont{LinBiolinum_R.otf}[
Path="fonts/",
BoldFont=LinBiolinum_RB.otf,
ItalicFont=LinBiolinum_RI.otf,
BoldItalicFont=LinBiolinum_RBO.otf,
]
\setsansfont{LinLibertine_M.otf}[
Path="fonts/",
BoldFont=LinLibertine_MB.otf,
ItalicFont=LinLibertine_MO.otf,
BoldItalicFont=LinLibertine_MBO.otf,
]
```

也可以类似ctex宏包的方式设置具体的字体配置文件,以方便调用,比如(参考sd44/notebook):

```
\GetIdInfo$Id: ctex.dtx 6471e87 2018-05-21 18:15:18 +0800 sd44 <sd44sd44@yeah.net $
  {Sourcesans fonts definition (CTEX)}
\ProvidesExplFile{ctex-fontset-sourcesans.def}
  {\ExplFileDate}{2.4.7}{\ExplFileDescription}
\sys_if_engine_pdftex:TF
  {
    \sys_if_output_pdf:TF
      { \ctex_fontset_error:n { sourcesans } }
      {
        \ctex_zhmap_case:nnn
          {
            \setCJKmainfont
              [
                  BoldFont = SourceHanSerifCN-Bold.otf ,
                ItalicFont = FZXKTJ.otf
              ] { SourceHanSerifCN-Regular.otf }
            \setCJKsansfont
              [
                BoldFont = SourceHanSansCN-Medium.otf
              ] { SourceHanSansCN-Normal.otf }
            \setCJKmonofont { FZFSJ.otf }
            \setCJKfamilyfont { zhsong }
              [
                BoldFont = SourceHanSerifCN-Bold.otf
              ] { SourceHanSerifCN-Regular.otf }
            \setCJKfamilyfont { zhhei }
              [
                BoldFont = SourceHanSansCN-Medium.otf
              ] { SourceHanSansCN-Normal.otf }
            \setCJKfamilyfont { zhfs } { FZFSJ.otf }
            \setCJKfamilyfont { zhkai }
              [
              BoldFont = FZCKJW.ttf
              ] { FZXKTJ.otf }
            \ctex_punct_set:n { sourcesans }
            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
            \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei }
            \ctex_punct_map_family:nn { \CJKttdefault } { zhfs }
            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
            \ctex_punct_map_bfseries:nn { \CJKrmdefault , zhsong } { zhsongb }
            \ctex_punct_map_bfseries:nn { \CJKsfdefault , zhhei } { zhheib }
          }
          {
            \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhsourcesansfonts }
            \ctex_punct_set:n { sourcesans }
            \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong }
            \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei }
            \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai }
          }
          { \ctex_fontset_error:n { sourcesans } }
      }
  }
  {
    \sys_if_engine_uptex:TF
      {
        \ctex_set_upfonts:nnnnnnn
          {SourceHanSerifCN-Regular.otf} {SourceHanSerifCN-Bold.otf}
          {FZXKTJ.otf} {FZCJKW.ttf}
          {SourceHanSansCN-Normal.otf} {SourceHanSansCN-Medium.otf}
          {FZFSJ.otf}
        \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb }
        \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb }
        \ctex_set_upfamily:nnn { zhfs } { upzhmono} {}
        \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {}
      }
      {
        \setCJKmainfont [ItalicFont = FZNewKai-Z03S]{ Source~Han~Serif~CN }
        \setCJKsansfont [BoldFont=Source~Han~Sans~CN~Medium]{ Source~Han~Sans~CN~Normal }
        \setCJKmonofont { FZFangSong-Z02S }
        \setCJKfamilyfont { zhsong } { Source~Han~Serif~CN }
        \setCJKfamilyfont { zhhei } [BoldFont=Source~Han~Sans~CN~Medium] { Source~Han~Sans~CN~Normal }
        \setCJKfamilyfont { zhfs }  { FZFangSong-Z02S }
        \setCJKfamilyfont { zhkai } [BoldFont=FZCuKaiS-R-GB]{ FZNewKai-Z03S }
      }
  }
\NewDocumentCommand \songti   { } { \CJKfamily { zhsong } }
\NewDocumentCommand \heiti    { } { \CJKfamily { zhhei } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } }
\NewDocumentCommand \kaishu   { } { \CJKfamily { zhkai } }
%% 
```

如果字体用的是ttc文件,因为ttc文件中包含有不同的字体,方式略有不同,需要利用fontindex属性,比如:
```
\setmainfont{Optima.ttc}[
Path = /System/Library/Fonts/ ,
UprightFeatures = {FontIndex=0} ,
BoldFeatures = {FontIndex=1} ,
ItalicFeatures = {FontIndex=2} ,
BoldItalicFeatures = {FontIndex=3} ,
]
```

文章先到这里结束,目前仅介绍了简单的使用方法,字体设置还有很多复杂功能,具体可以参考fontspec,xecjk,unicode-math宏包的详细说明。

 

下面给出一个简单的文档:

```

\documentclass[twoside]{article}
\usepackage{ctex}
\usepackage{unicode-math}

\setCJKmainfont[%
%BoldFont = {FontIndex=6},
%ItalicFont = {FontIndex=0},
%BoldItalicFont = {FontIndex=5},
%SlantedFont = {FontIndex=1},]
%BoldSlantedFont = {FontIndex=4},
%SmallCapsFont = {FontIndex=2},
BoldFeatures={FontIndex=18},
%ItalicFeatures={FontIndex=0},
%BoldItalicFeatures={FontIndex=5},
%SlantedFeatures={FontIndex=1},
%BoldSlantedFeatures={FontIndex=4},
%SmallCapsFeatures={FontIndex=2},
UprightFeatures={FontIndex=6}%upright就是normal
]{SourceHanSerif.ttc} %[Path="d:/fonts"] %BoldFont={simhei.ttf},ItalicFont=simkai.ttf

%BoldFont = 〈fontname〉
%ItalicFont = 〈fontname〉
%BoldItalicFont = 〈font name〉
%SlantedFont = 〈fontname〉
%BoldSlantedFont = 〈font name〉
%SmallCapsFont = 〈fontname〉

%BoldFeatures={〈features〉}
%ItalicFeatures={〈features〉}
%BoldItalicFeatures={〈features〉}
%SlantedFeatures={〈features〉}
%BoldSlantedFeatures={〈features〉}
%SmallCapsFeatures={〈features〉}

\setCJKsansfont[%
%BoldFont = {FontIndex=6},
%ItalicFont = {FontIndex=0},
%BoldItalicFont = {FontIndex=5},
%SlantedFont = {FontIndex=1},
%BoldSlantedFont = {FontIndex=4},
%SmallCapsFont = {FontIndex=2},
BoldFeatures={FontIndex=26},
%ItalicFeatures={FontIndex=0},
%BoldItalicFeatures={FontIndex=5},
%SlantedFeatures={FontIndex=1},
%BoldSlantedFeatures={FontIndex=4},
%SmallCapsFeatures={FontIndex=2},
UprightFeatures={FontIndex=10}%
]{SourceHanSans.ttc}
%\setCJKmonofont[Path="d:/fonts"]{simfang.ttf}

%Libertinus,过渡风格
%\setmainfont{Libertinus Serif}
%\setsansfont{Libertinus Sans}
%\setmonofont{Libertinus Mono}
%\setmathfont{Libertinus Math}

%CM/LM风格,现代风格,默认的设置,调整数学和非称线字体
%\setsansfont{FreeSans}
%\setmathfont{Latin Modern Math}

%CM/LM风格,现代风格,全LM 字体
%\setmainfont{Latin Modern Roman}
%\setsansfont{Latin Modern Sans}
%\setmonofont{Latin Modern Mono}
%\setmathfont{Latin Modern Math}

%CM/LM风格,现代风格,全LM 字体
%\setmainfont{CMU Serif}
%\setsansfont{CMU Sans Serif}
%\setmonofont{CMU Typewriter Text}
%\setmathfont{Latin Modern Math}

%sourcecode
%\usepackage{sourceserifpro}
%\usepackage{sourcesanspro}
%\usepackage{sourcecodepro}
%\setmathfont{Latin Modern Math}
%\setmainfont{Source Serif Pro}
%\setsansfont{Source Sans Pro}
%\setmonofont{Source Code Pro}

\usepackage{geometry}
\geometry{paperwidth=21cm,paperheight=13.5cm,top=0.5cm, bottom=0.0cm, left=0.5cm,right=0.5cm}
\usepackage{xcolor}
\usepackage[CJKbookmarks,colorlinks,bookmarksnumbered=true,pdfstartview=FitH,linkcolor=blue]{hyperref}

\usepackage[backend=biber,style=gb7714-2015]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Inproceedings{refa,
  Title                    = {Interference cartography for hierarchical dynamic spectrum access},
  Address                  = {Chicago, IL},
  Author                   = {AlayaFeki, A. and B. Sayrac and S. Ben Jemaa and E. Moulines},
  editor={Name, B and Dome, C},
  Booktitle                = {Proc. IEEE Symp. on New Frontiers in Dynamic Spectrum Access Networks},
  shortbooktitle ={DySPAN},
  Date                     = {2008-10},
  Pages                    = {1-5}
}

@Inproceedings{refb,
  Title                    = {Interference cartography for hierarchical dynamic spectrum access},
  Address                  = {Chicago, IL},
  editor={Name, B and Dome, C},
  Author                   = {BlayaFeki, A. and B. Sayrac and S. Ben Jemaa and E. Moulines},
  Booktitle                = {Proc. IEEE Symp. on New Frontiers in Dynamic Spectrum Access Networks},
  shortbooktitle ={DySPAN},
  Date                     = {2008-10},
  Pages                    = {1-5}
}

@Inproceedings{FOURNEY1971-17-38,
  Title                    = {Advances in holographic photoelasticity},
  Author                   = {M E FOURNEY},
  Booktitle                = {Symposium on Applications of Holography in Mechanics},
  shortbooktitle ={AHM},
  Date                     = {1971},
  Pages                    = {17-38},
  Publisher                = {ASME},
  Location                 = {New York}
}

@Inproceedings{裴丽生1981-2-10,
  Title                    = {在中国科协技术期刊编辑工作经验交流会上的讲话},
  Author                   = {裴丽生},
  Booktitle                = {中国科协学术期刊编辑工作经验交流会资料选},
  shortbooktitle ={科协学术},
  Date                     = {1981},
  Pages                    = {2-10},
  Institution              = {中国科学技术协会学会工作部},
  Location                 = {北京}
}

@Book{Simon2001--,
  Title                    = {Spread Spectrum Communications Handbook},
  Address                  = {New York City},
  Author                   = {Simon, M. K. and Omura,J. K. and Scholtz,R. A. and Levitt,B. K.},
  Publisher                = {McGraw-Hill, Inc.},
  Year                     = {2001}
}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}
编译信息:biblatex v\versionofbiblatex;gb7714-2015*.* version number \versionofgbtstyle.

\section{文献表}


\begin{tabular}{|l|l|l|r|}
  \hline
  命令A & 结果A & 结果B & 命令B \\\hline
  % after \\: \hline or \cline{col1-col2} \cline{col3-col4} ...
  {\textbackslash mdseries 中文字体lI10Oo} & {\mdseries 中文字体lI10Oo} & \textmd{中文字体lI10Oo} & {\textbackslash textmd 中文字体lI10Oo} \\
  {\textbackslash bfseries 中文字体lI10Oo} & {\bfseries 中文字体lI10Oo} & \textbf{中文字体lI10Oo} & {\textbackslash textbf 中文字体lI10Oo} \\
  {\textbackslash upshape 中文字体lI10Oo} & {\upshape 中文字体lI10Oo} & \textup{中文字体lI10Oo} & {\textbackslash textup 中文字体lI10Oo} \\
  {\textbackslash itshape 中文字体lI10Oo} & {\itshape 中文字体lI10Oo} & \textit{中文字体lI10Oo} & {\textbackslash textit 中文字体lI10Oo} \\
  {\textbackslash slshape 中文字体lI10Oo} & {\slshape 中文字体lI10Oo} & \textsl{中文字体lI10Oo} & {\textbackslash textsl 中文字体lI10Oo} \\
  {\textbackslash scshape 中文字体lI10Oo} & {\scshape 中文字体lI10Oo} & \textsc{中文字体lI10Oo} & {\textbackslash textsc 中文字体lI10Oo} \\
  {\textbackslash sffamily 中文字体lI10Oo} & {\sffamily 中文字体lI10Oo} & \textsf{中文字体lI10Oo} & {\textbackslash textsf  中文字体lI10Oo} \\
  {\textbackslash ttfamily 中文字体lI10Oo} & {\ttfamily 中文字体lI10Oo} & \texttt{中文字体lI10Oo} & {\textbackslash texttt  中文字体lI10Oo} \\
  {\textbackslash rmfamily 中文字体lI10Oo} & {\rmfamily 中文字体lI10Oo} & \textrm{中文字体lI10Oo} & {\textbackslash textrm 中文字体lI10Oo} \\
  {\textbackslash normalfont 中文字体lI10Oo} & {\normalfont 中文字体lI10Oo} & \textnormal{中文字体lI10Oo} & {\textbackslash textnormal 中文字体lI10Oo} \\
  \hline
\end{tabular}

{\ttfamily\upshape 期刊编辑中文字体abcdlI10Oo}{\ttfamily\bfseries 期刊编辑中文字体abcdlI10Oo}{\ttfamily\itshape 期刊编辑中文字体abcdlI10Oo}

{\sffamily\upshape 期刊编辑中文字体abcdlI10Oo}{\sffamily\bfseries 期刊编辑中文字体abcdlI10Oo}{\sffamily\itshape 期刊编辑中文字体abcdlI10Oo}

{\rmfamily\upshape 期刊编辑中文字体abcdlI10Oo}{\rmfamily\bfseries 期刊编辑中文字体abcdlI10Oo}{\rmfamily\itshape 期刊编辑中文字体abcdlI10Oo}


文献
\cite{refa}
\cite{refb}
\cite{FOURNEY1971-17-38}
\cite{裴丽生1981-2-10}
\cite{Simon2001--}

\printbibliography%[heading=subbibintoc,title=【参考文献】]
\end{document} 

```

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值