Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quarto-ext/latex-environment
Quarto extension to output custom LaTeX environments.
https://github.com/quarto-ext/latex-environment
quarto quarto-extension
Last synced: 3 months ago
JSON representation
Quarto extension to output custom LaTeX environments.
- Host: GitHub
- URL: https://github.com/quarto-ext/latex-environment
- Owner: quarto-ext
- License: mit
- Created: 2022-06-29T20:30:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-07T20:30:58.000Z (about 1 year ago)
- Last Synced: 2024-06-25T04:57:04.478Z (5 months ago)
- Topics: quarto, quarto-extension
- Language: Lua
- Homepage: https://quarto-ext.github.io/latex-environment/
- Size: 4 MB
- Stars: 29
- Watchers: 2
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# latex-environment
## Overview
This is Quarto extension that enables `divs` to be output as a custom environment in LaTeX. This is useful when you'd like to share content between LaTeX and other formats, but need the content to be placed in an environment when emitting LaTeX.
## Installation
To install this extension in your current directory (or into the Quarto project that you're currently working in), use the following command:
```
quarto add quarto-ext/latex-environment
```## Usage
### Environments
Divs with a class name listed in the in the `environments` key will be emitted in LaTeX as an environment with the provided name (or the class name itself if no name is provided). All of the following are valid:
```yaml
environments: center
``````yaml
environments: [center]
``````yaml
environments:
center: center-env
```#### Example
```markdown
---
title: LaTeX Environment
format:
pdf: default
html: default
filters:
- latex-environment
environments: [center]
---::: {.center}
The contents of this div will be output in a `center`
LaTeX environment, but will appear in HTML (and any other output
format as a simple div with the class `center`)
:::
```#### Options and Arguments
In addition, you may specify options and arguments for the environment as attributes of the div. For example:
```markdown
::: {.foo options="option" arguments="argument"}
body
:::
```would transform to:
```tex
\begin{foo}[option]{argument}
body
\end{foo}
```### Commands
Spans with a class name listed in the in the `commands` key will be emitted in LaTeX as a command with the provided name (or the class name itself if no name is provided). All of the following are valid:
```yaml
commands: ce
``````yaml
commands: [ce]
``````yaml
commands:
ce: ce-command
```#### Options
You may also provide options for commands using the `options` attribute. For example:
```
[Content]{.command options="option1"}
```generates the following:
```
\command[option1]{Content}
```## Example
```markdown
---
title: LaTeX Command
format:
pdf:
include-in-header:
text: |
\usepackage{mhchem}
html: default
filters:
- latex-environment
commands: [ce]
---This will replace spans of class `ce` with the `\ce{}` command for LaTeX output,
but leave the spans intact for HTML output. So `[H2SO4]{.ce}` becomes [H2SO4]{.ce}.```