如何更改 LaTeX(Anki)中的字体和字体颜色?

如何更改 LaTeX(Anki)中的字体和字体颜色?

首先我要说的是,在过去的 24 小时里,我几乎没有接触过 LaTeX 或 Python,我一直在疯狂地尝试弄清楚命令、函数等是什么意思!我也搜索了无数的线索,它们有所帮助,但恐怕我被困在了这一点上。如果我用错了词汇,请提前道歉!

我目前正在使用 Anki (2.1) 为 MCAT 备考,并将卡片定制成某种样子。我想编辑我输入的 LaTeX 方程式(我想记住的公式)的外观,以便它们在我的卡片上看起来更整洁。我设法弄清楚了如何使背景透明(我安装了“编辑 Latex 构建过程”插件),但我不知道如何将字体更改为类似于打字机的字体以及如何将字体颜色更改为白色(或至少是我想要的颜色)。

在标题(序言?)中我放入了:

\documentclass[12pt]{article}
\setmainfont{lmtt}
\fontfamily{lmtt}\selectfont
\special{papersize=3in,5in}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,amsmath}
\pagestyle{empty}
\setlength{\parindent}{0in}
\usepackage{xcolor}
\textcolor{white}
\begin{document}

此时,我甚至不知道我是否在正确的位置输入了代码......

如能得到任何帮助我将非常感激 — — 提前谢谢您!:)

答案1

这是一个可以扩展的模板。我尝试将其保持在最低限度,同时支持您要求的特定功能。它可能会变得更加花哨。不过,添加卡片应该很简单。

\documentclass[12pt]{article}
% Sets up the geometry of each page to fit on one of your cards:
\usepackage[paperwidth=5in, paperheight=3in]{geometry}
% Supports the same color names as HTML and CSS:
\usepackage[svgnames, Svgnames, HTML]{xcolor}
% Loads amsmath plus some extra stuff.
\usepackage{mathtools}
% Enables modern, Unicode fonts:
\usepackage{unicode-math}

% Make all the fonts in the document match each other’s height:
\defaultfontfeatures{ Scale = MatchUppercase, Ligatures = TeX }

% I would not normally advise you to use a monospaced font as your main font,
% but if you want to, here is how:
\setmainfont{Anonymous Pro}[Scale = 1.0]
\setmonofont{Anonymous Pro}

% If you want to select a monospace font only some of the time, you might try
% the alltt package.

% You will also need a math font.  This sets the letters in math mode to the
% same as your text font, and declares a fallback for the rest:
\setmathfont{GFS Neohellenic Math}
\setmathfont[range=up]{Anonymous Pro}
\setmathfont[range=it]{Anonymous Pro Italic}
\setmathfont[range=bfup]{Anonymous Pro Bold}
\setmathfont[range=bfit]{Anonymous Pro Bold Italic}

% You would declare your foreground and background colors here.

\begin{document}
\section*{\color{Navy}Trigonometric identities}

\begin{align*}
 &\text{SOH} & &\text{CAH} \\
   \sin^2 x &= 1 - \cos^2 x &
   \cos^2 x &= 1 - \sin^2 x \\
 \csc x &= \frac{1}{\sin x} &
   \sec x &= \frac{1}{\cos x} \\
 \sin (-x) &= - \sin x &
   \cos (-x) &= \cos x
\end{align*}
\clearpage

\section*{\color{Navy}Law of Sines and Cosines}

\begin{itemize}
  \item \( \frac{\sin \alpha}{\Alpha} = 
           \frac{\sin \beta}{\Beta} =
           \frac{\sin \gamma}{\Gamma} \)
  \item \( C^2 = A^2 + B^2 - 2AB \cdot \cos c \)
\end{itemize}

\end{document}

卡 1

卡 2

因为它使用现代的 Unicode 字体,所以它只能使用lualatex或进行编译xelatex

虽然我没有在这里演示它,因为您无法在示例图像中看到它,\nopagecolor但可以将背景设置为透明,并且可以\color{white}设置前景色。这两个命令都来自xcolor

为了向后兼容

由于您没有该anonymouspro软件包并且似乎仅限于 PDFLaTeX,因此这里有一个使用旧软件包的版本:

\documentclass[12pt]{article}
% Sets up the geometry of each page to fit on one of your cards:
\usepackage[paperwidth=5in, paperheight=3in]{geometry}
% Sets up the legacy 8-bit font encodings:
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc} % The default since 2018.
% Loads some common math symbols.  Mostly overwritten by newtx.
\usepackage{amssymb}
% Loads newtx math with newtxtt as the default text font:
\usepackage[ttdefault]{newtxtt}
\usepackage{newtxmath}
% Uses the text font for math symbols:
\usepackage{mathastext}
% Supports the same color names as HTML and CSS:
\usepackage[svgnames, Svgnames, HTML]{xcolor}
% Loads amsmath plus some extra stuff.
\usepackage{mathtools}
% If you need additional \mathscr, \mathcal, \mathfrak or \mathbb alphabets,
% consider loading mathalfa here.  This template also would need to load some
% extra packages to support Greek.

% You would declare your foreground and background colors here.

\begin{document}
\section*{\color{Navy}Trigonometric identities}

\begin{align*}
 &\text{SOH} & &\text{CAH} \\
   \sin^2 x &= 1 - \cos^2 x &
   \cos^2 x &= 1 - \sin^2 x \\
 \csc x &= \frac{1}{\sin x} &
   \sec x &= \frac{1}{\cos x} \\
 \sin (-x) &= - \sin x &
   \cos (-x) &= \cos x
\end{align*}
\clearpage

\section*{\color{Navy}Law of Sines and Cosines}

\begin{itemize}
  \item \( \frac{\sin a}{A} = 
           \frac{\sin b}{B} =
           \frac{\sin c}{C} \)
  \item \( C^2 = A^2 + B^2 - 2AB \cdot \cos c \)
\end{itemize}

\end{document}

卡 1 卡 2

相关内容