mirror of
https://github.com/tonsky/FiraCode.git
synced 2024-10-05 17:17:34 +03:00
TeX code markup
parent
2d2558d22a
commit
6e212fb951
@ -1,67 +1,73 @@
|
|||||||
This page is intended for those who wish to use the Fira Code font in the LaTeX *output* files. If you wish to use Fira Code to display your LaTeX source files, then please check whether your LaTeX editor supports Fira Code or not.
|
This page is intended for those who wish to use the Fira Code fonts in the LaTeX *output* files. If you wish to use Fira Code to display your LaTeX source files, then please check whether your LaTeX editor supports Fira Code or not.
|
||||||
|
|
||||||
## Activate ligatures in `lstlisting`
|
## Activate ligatures in `lstlisting`
|
||||||
|
|
||||||
The [`lstfiracode`](https://www.ctan.org/pkg/lstfiracode) package defines `FiraCodeStyle` for the use with the [`listings`](https://www.ctan.org/pkg/listings) package. Here is a sample LaTeX document:
|
The [`lstfiracode`](https://ctan.org/pkg/lstfiracode) package defines `FiraCodeStyle` for the use with the [`listings`](https://ctan.org/pkg/listings) package. Here is a sample LaTeX document:
|
||||||
|
|
||||||
% !TeX program = XeLaTeX or LuaLaTeX
|
```tex
|
||||||
% !TeX encoding = UTF-8 Unicode
|
% !TeX program = XeLaTeX or LuaLaTeX
|
||||||
\documentclass{article}
|
% !TeX encoding = UTF-8 Unicode
|
||||||
\usepackage{fontspec}
|
\documentclass{article}
|
||||||
\setmonofont{Fira Code}[
|
\usepackage{fontspec}
|
||||||
|
\setmonofont{Fira Code}[
|
||||||
Contextuals=Alternate % Activate the calt feature
|
Contextuals=Alternate % Activate the calt feature
|
||||||
]
|
]
|
||||||
\usepackage{listings}
|
\usepackage{listings}
|
||||||
\usepackage{lstfiracode} % https://www.ctan.org/pkg/lstfiracode
|
\usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
|
||||||
\lstset{
|
\lstset{
|
||||||
language=C++,
|
language=C++,
|
||||||
style=FiraCodeStyle, % Use predefined FiraCodeStyle
|
style=FiraCodeStyle, % Use predefined FiraCodeStyle
|
||||||
basicstyle=\ttfamily % Use \ttfamily for source code listings
|
basicstyle=\ttfamily % Use \ttfamily for source code listings
|
||||||
}
|
}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
/* A simple C++ program */
|
/* A simple C++ program */
|
||||||
int main() {
|
int main() {
|
||||||
cout << "Hello World"; // prints Hello World
|
cout << "Hello World"; // prints Hello World
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
```
|
||||||
|
|
||||||
## Activate ligatures in `verbatim`
|
## Activate ligatures in `verbatim`
|
||||||
|
|
||||||
The [`lstfiracode`](https://www.ctan.org/pkg/lstfiracode) package also supports the `verbatim` environment. Here is a sample LaTeX document:
|
The [`lstfiracode`](https://ctan.org/pkg/lstfiracode) package also supports the `verbatim` environment. Here is a sample LaTeX document:
|
||||||
|
|
||||||
% !TeX program = XeLaTeX or LuaLaTeX
|
```tex
|
||||||
% !TeX encoding = UTF-8 Unicode
|
% !TeX program = XeLaTeX or LuaLaTeX
|
||||||
\documentclass{article}
|
% !TeX encoding = UTF-8 Unicode
|
||||||
\usepackage{fontspec}
|
\documentclass{article}
|
||||||
\setmonofont{Fira Code}[
|
\usepackage{fontspec}
|
||||||
|
\setmonofont{Fira Code}[
|
||||||
Contextuals=Alternate % Activate the calt feature
|
Contextuals=Alternate % Activate the calt feature
|
||||||
]
|
]
|
||||||
\usepackage{listings}
|
\usepackage{listings}
|
||||||
\usepackage{lstfiracode} % https://www.ctan.org/pkg/lstfiracode
|
\usepackage{lstfiracode} % https://ctan.org/pkg/lstfiracode
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\ActivateVerbatimLigatures
|
\ActivateVerbatimLigatures
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
A<-www>>=B
|
A<-www>>=B
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
```
|
||||||
|
|
||||||
If you do not want to load the `lstfiracode` package, here is another solution:
|
If you do not wish to load the `lstfiracode` package, here is another solution:
|
||||||
|
|
||||||
% !TeX program = XeLaTeX or LuaLaTeX
|
```tex
|
||||||
% !TeX encoding = UTF-8 Unicode
|
% !TeX program = XeLaTeX or LuaLaTeX
|
||||||
\documentclass{article}
|
% !TeX encoding = UTF-8 Unicode
|
||||||
\usepackage{fontspec}
|
\documentclass{article}
|
||||||
\setmonofont{Fira Code}[
|
\usepackage{fontspec}
|
||||||
|
\setmonofont{Fira Code}[
|
||||||
Contextuals=Alternate % Activate the calt feature
|
Contextuals=Alternate % Activate the calt feature
|
||||||
]
|
]
|
||||||
\makeatletter
|
\makeatletter
|
||||||
\renewcommand*\verbatim@nolig@list{} % Empty the no-ligature list
|
\renewcommand*\verbatim@nolig@list{} % Empty the no-ligature list
|
||||||
\makeatother
|
\makeatother
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
A<-www>>=B
|
A<-www>>=B
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user