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

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

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

2024-02-04 11:43| 来源: 网络整理| 查看: 265

文章目录 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} # 定义字体 \newfontfamily\chalkd{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}

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

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}

也没用。

还看了很多别的操作,试了下都没用。。。找到有用的还是费了不少时间的。 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}} \newfontfamily\chalkd{Chalkduster.ttf} \newfontfamily\chalkb{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}

关于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-folder\setmainfont 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


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3