首页 > 分享 > 【已解决】如何设置、更换LaTeX Beamer的字体?以及调整正文所使用的字体(如从Times New Roman改变为Arial)、定义字体大小等操作

【已解决】如何设置、更换LaTeX Beamer的字体?以及调整正文所使用的字体(如从Times New Roman改变为Arial)、定义字体大小等操作

最新推荐文章于 2024-05-14 09:24:16 发布

宇内虹游 于 2021-12-13 13:53:38 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

文章目录 1. 前言2. 关于字体3. Overleaf支持的字体4. 直接上代码!4.1. 做过的错误尝试 5. 小结6. 参考文献

1. 前言

创作开始时间:2021年12月12日21:21:07

感觉用LaTeX很简单,因为Overleaf上的模板太多了,但是要精通LaTeX,感觉要掌握的东西太多。本文主要对LaTeX Beamer中的字体设置进行研究。

备注:
第4节:“直接上代码!”包含实例代码。可以直接跳到这一节查看。

2. 关于字体

LaTeX的字体属性有四种:

familyshapeseriessize

其中family属性主要可以归为三类:

serif 有衬线字体sans serif (也叫做roman)。无衬线字体monospaced 等宽字体

对于中文来说,宋体属于serif 字体,而黑体、幼圆、雅黑则属于sans serif 字体。
而英文,常用的 serif 字体为Times New Roman,常用的 sans serif 字体为Arial,Tahoma。

参考:

https://baike.baidu.com/item/serif/4199080?fr=aladdinhttps://en.wikibooks.org/wiki/LaTeX/FontsLaTeX字体属性及其在中文Beamer中的使用 https://lttt.vanabel.cn/2018/06/04/latexzitishuxingjiqizaizhongwenbeamerzhongdeshiyong.html 这个还挺详细的。值得一看

3. Overleaf支持的字体

首先,所有的字体:

Fontname https://mirror-hk.koddos.net/CTAN/info/fontname/fontname.pdf 这个是官方文档

overleaf支持的字体没有那么多,具体可见官网(也挺多了):

Which OTF or TTF fonts are supported via fontspec? https://es.overleaf.com/learn/latex/Questions/Which_OTF_or_TTF_fonts_are_supported_via_fontspec%3F

4. 直接上代码!

documentclass[xcolor=dvipsnames,9pt]{beamer} % 使用theme usetheme{CambridgeUS} useinnertheme{circles} % 使用字体必备的包 usepackage{fontspec} # 定义字体 newfontfamilychalkd{DejaVu Sans} # 设置beamer的字体 setbeamerfont{normal text}{family=chalkd,series=mdseries} setbeamerfont{alerted text}{family=chalkd,series=bfseries} setbeamerfont{frametitle}{family=chalkd,series=bfseries} % ,size={fontsize{32}{36}} AtBeginDocument{usebeamerfont{normal text}} title[Example]{Just an example!} author[xxx]{xxx} date{9th Dec, 2021} begin{document} begin{frame} titlepage end{frame} section{Hello world} begin{frame}{Hello world now.} Hello world to every one. end{frame} end{document}

1234567891011121314151617181920212223242526272829303132333435

效果如下:
在这里插入图片描述

DejaVu Sans是一种无衬线字体。

换成:Alfios(一种有衬线字体,从https://es.overleaf.com/learn/latex/Questions/Which_OTF_or_TTF_fonts_are_supported_via_fontspec%3F oveleaf官网找的)之后,就变成了下面的样子:

在这里插入图片描述

4.1. 做过的错误尝试

使用setmainfont{font/Palatino.ttf}或者setmainfont{palatino},貌似setmainfont对Beamer没用。使用setmainfont[ExternalLocation=font/]{POLYA.OTF}[Ligatures=TeX],没用defaultfontfeatures{Ligatures=TeX},没用使用overleaf官方提供的example:

setromanfont{Times New Roman} setsansfont{Arial} setmonofont[Color={0019D4}]{Courier New} 123

也没用。

还看了很多别的操作,试了下都没用。。。找到有用的还是费了不少时间的。

5. 小结

创作结束时间:

6. 参考文献

很多。

有用的:

latex - 如何使用setbeamerfont 设置任何字体大小(例如 32pt)? https://www.coder.work/article/6681293参考别人的代码:

usetheme{default} usepackage{mathpazo} usepackage{fontspec} setbeamertemplate{background canvas}{includegraphics [width=paperwidth]{blackboard_bk.pdf}} newfontfamilychalkd{Chalkduster.ttf} newfontfamilychalkb{Chalkboard.ttc} setbeamerfont*{normal text}{family = chalkd} setbeamerfont{alerted text}{family = chalkd} setbeamerfont{structure}{family = chalkd} setbeamerfont{title}{family = chalkd, size = Huge} setbeamercolor{normal text}{fg=white} setbeamercolor{alerted text}{fg=yellow!80} setbeamercolor{structure}{fg=yellow!80} setbeamercolor{frametitle}{fg=white} setbeamercolor{title}{fg=white} setbeamertemplate{blocks}[shadow=false] setbeamercolor{block body}{fg=normal text.bg!90!black} setbeamercolor{block body example}{bg=normal text.bg!90!black} setsansfont{Chalkduster.ttf} %setmonofont{Chalkduster.ttf}

123456789101112131415161718192021222324

关于setmainfont :

How to setmainfont when “randomfont.ttf” is in different folder? https://tex.stackexchange.com/questions/230186/how-to-setmainfont-when-randomfont-ttf-is-in-different-foldersetmainfont vs fontspec https://tex.stackexchange.com/questions/352804/setmainfont-vs-fontspec

设置字体:

Setting beamer text font https://tex.stackexchange.com/questions/489207/setting-beamer-text-fontChanging fonts in the body in beamer [duplicate] https://tex.stackexchange.com/questions/419920/changing-fonts-in-the-body-in-beamerHow to enforce a font series in beamer for normal/default text? https://tex.stackexchange.com/questions/320223/how-to-enforce-a-font-series-in-beamer-for-normal-default-textBeamer Font: Change its Size, Family and style By Admin August 18, 2021 https://latex-beamer.com/tutorials/beamer-font/Beamer template setbeamerfont bfseries https://tex.stackexchange.com/questions/236450/beamer-template-setbeamerfont-bfseriesWhat are all the possible first arguments to setbeamerfont? tex.stackexchange.com/questions/183052/what-are-all-the-possible-first-arguments-to-setbeamerfontUsing a TrueType font in LaTeX with XeTeX https://gordonlesti.com/using-a-truetype-font-in-latex-with-xetex/How to change fontspec’s default options https://tex.stackexchange.com/questions/431585/how-to-change-fontspec-s-default-optionslatex字体设置 https://blog.csdn.net/wkd22775/article/details/51778920How to modify Beamer theme? https://tex.stackexchange.com/questions/433595/how-to-modify-beamer-theme

xelatex:

Getting started with XeLaTeX https://robjhyndman.com/hyndsight/xelatex/How to Use Different Fonts on Overleaf https://hongtaoh.com/en/2020/11/13/overleaf-latex-fonts/Toying with Fonts in LaTeX huisaddison.com/blog/fonts-in-latex.htmlXeLaTeX https://es.overleaf.com/learn/latex/XeLaTeX#The_basics:_Times_New_RomanHow to choose a specific weight from a font family using fontspec and XeLaTeX https://tex.stackexchange.com/questions/62603/how-to-choose-a-specific-weight-from-a-font-family-using-fontspec-and-xelatexHow to define a new font family on Beamer? https://tex.stackexchange.com/questions/177317/how-to-define-a-new-font-family-on-beamer#comment410588_177317

官方文档:

The fontspec package https://mirror-hk.koddos.net/CTAN/macros/unicodetex/latex/fontspec/fontspec.pdf

相关知识

论文中的数字一般用什么字体写好看
CSS花边无衬线字体和有衬线字体
字体笔记
CSS 字体
字体基础知识:衬线字体和无衬线字体
Web 字体 font
衬线字体和无衬线字体
衬线字体
花漾字体有哪些
matlab绘图修改坐标轴数字字体大小及坐标轴自定义

网址: 【已解决】如何设置、更换LaTeX Beamer的字体?以及调整正文所使用的字体(如从Times New Roman改变为Arial)、定义字体大小等操作 https://m.huajiangbk.com/newsview740750.html

所属分类:花卉
上一篇: 免费字体下载!一款拥有七个字重的
下一篇: 优雅轻奢的英文无衬线花饰字体