Skip to content

Commit 3891a29

Browse files
docs: add preamble docs and move the internal docs to CONTRIBUTING.md (#192)
* docs: add preamble docs and move the internal docs to `CONTRIBUTING.md` * docs: remove a variable * docs: edit title * docs: remove redundant words
1 parent 18ef913 commit 3891a29

3 files changed

Lines changed: 63 additions & 23 deletions

File tree

CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Contributing to MiTeX
22

3+
Currently, MiTeX maintains following three parts of code:
4+
5+
- A TeX parser library written in **Rust**, see [mitex-lexer](https://github.com/mitex-rs/mitex/tree/main/crates/mitex-lexer) and [mitex-parser](https://github.com/mitex-rs/mitex/tree/main/crates/mitex-parser).
6+
- A TeX to Typst converter library written in **Rust**, see [mitex](https://github.com/mitex-rs/mitex/tree/main/crates/mitex).
7+
- A list of TeX packages and commands written in **Typst**, which then used by the typst package, see [MiTeX Command Specification](https://github.com/mitex-rs/mitex/tree/main/packages/mitex/specs).
8+
9+
For a translation process, for example, we have:
10+
11+
```
12+
\frac{1}{2}
13+
14+
===[parser]===> AST ===[converter]===>
15+
16+
#eval("$frac(1, 2)$", scope: (frac: (num, den) => $(num)/(den)$))
17+
```
18+
19+
You can use the `#mitex-convert()` function to get the Typst Code generated from LaTeX Code.
20+
21+
### Adding missing TeX commands
22+
23+
Even if you don't know Rust at all, you can still add missing TeX commands to MiTeX by modifying [specification files](https://github.com/mitex-rs/mitex/tree/main/packages/mitex/specs), since they are written in typst! You can open an issue to acquire the commands you want to add, or you can edit the files and submit a pull request.
24+
25+
In the future, we will provide the ability to customize TeX commands, which will make it easier for you to use the commands you create for yourself.
26+
327
## Installing Dependencies
428

529
You should install [Typst](https://github.com/typst/typst?tab=readme-ov-file#installation) and [Rust](https://www.rust-lang.org/tools/install) for running the build script.

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,36 +118,38 @@ Another example is that MiTeX transforms `(\frac{1}{2})` into `\(frac(1, 2)\)` i
118118

119119
**Certainly, the greatest advantage is that you can directly write LaTeX content in Typst without the need for manual conversion!**
120120

121-
## Submitting Issues
122-
123-
If you find missing commands or bugs of MiTeX, please feel free to submit an issue [here](https://github.com/mitex-rs/mitex/issues).
121+
### Adding new commands
124122

125-
## Contributing to MiTeX
123+
There are two kinds of commands to add:
126124

127-
Currently, MiTeX maintains following three parts of code:
125+
- **Commonly used commands**: If there are some builtin or commonly used commands missing in MiTeX, you can submit an issue or contribute them according to [Adding missing TeX commands.](./CONTRIBUTING.md#adding-missing-tex-commands)
128126

129-
- A TeX parser library written in **Rust**, see [mitex-lexer](https://github.com/mitex-rs/mitex/tree/main/crates/mitex-lexer) and [mitex-parser](https://github.com/mitex-rs/mitex/tree/main/crates/mitex-parser).
130-
- A TeX to Typst converter library written in **Rust**, see [mitex](https://github.com/mitex-rs/mitex/tree/main/crates/mitex).
131-
- A list of TeX packages and commands written in **Typst**, which then used by the typst package, see [MiTeX Command Specification](https://github.com/mitex-rs/mitex/tree/main/packages/mitex/specs).
127+
- **Special commands (Preambles)**: If you want to add some special commands (preambles) for your own use, you can define them by `\newcommand` or `\newenvironment` and override the mitex function in your. Example:
132128

133-
For a translation process, for example, we have:
129+
````typ
130+
#let mitex = (content, ..args) => mitex.with(..args)({
131+
```tex
132+
\newcommand{\f}[2]{#1f(#2)}
133+
```.text
134+
content.text
135+
})
136+
````
134137

135-
```
136-
\frac{1}{2}
137-
138-
===[parser]===> AST ===[converter]===>
139-
140-
#eval("$frac(1, 2)$", scope: (frac: (num, den) => $(num)/(den)$))
141-
```
138+
And use them in your Typst code:
142139

143-
You can use the `#mitex-convert()` function to get the Typst Code generated from LaTeX Code.
144-
145-
### Add missing TeX commands
140+
````typ
141+
#show raw.where(lang: "mitex"): mitex
142+
```mitex
143+
\f\relax{x} = \int_{-\infty}^\infty
144+
\f\hat\xi\,e^{2 \pi i \xi x}
145+
\,d\xi
146+
```
147+
````
146148

147-
Even if you don't know Rust at all, you can still add missing TeX commands to MiTeX by modifying [specification files](https://github.com/mitex-rs/mitex/tree/main/packages/mitex/specs), since they are written in typst! You can open an issue to acquire the commands you want to add, or you can edit the files and submit a pull request.
149+
## Submitting Issues
148150

149-
In the future, we will provide the ability to customize TeX commands, which will make it easier for you to use the commands you create for yourself.
151+
If you find missing commands or bugs of MiTeX, please feel free to submit an issue [here](https://github.com/mitex-rs/mitex/issues).
150152

151-
### Develop the parser and the converter
153+
## Contributing
152154

153-
See [CONTRIBUTING.md](https://github.com/mitex-rs/mitex/blob/main/CONTRIBUTING.md).
155+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import "../lib.typ": *
2+
3+
#let mitex = (it, ..args) => mitex.with(..args)({
4+
```tex
5+
\newcommand{\f}[2]{#1f(#2)}
6+
```.text
7+
it.text
8+
})
9+
10+
#mitex(```latex
11+
\f\relax{x} = \int_{-\infty}^\infty
12+
\f\hat\xi\,e^{2 \pi i \xi x}
13+
\,d\xi
14+
```)

0 commit comments

Comments
 (0)