Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Ignore PDF files
*.pdf
*.pdf
/tests/temp
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ module:
cp ./LICENSE $(TARGET_DIR)/
cp -r ./src/* $(TARGET_DIR)/src/
awk '{gsub("https://typst.app/universe/package/$(PACKAGE_NAME)", "https://github.com/Typsium/$(PACKAGE_NAME)");print}' ./README.md > $(TARGET_DIR)/README.md



bump-minor:
@current_version=$$(grep '^version' typst.toml | awk -F ' = ' '{print $$2}' | tr -d '"'); \
new_version=$$(echo $$current_version | awk -F. '{printf "%d.%d.%d", $$1, $$2+1, $$3}'); \
sed -i '' "s|^version = .*|version = \"$$new_version\"|" typst.toml; \
sed -i '' "s|@preview/typsium:$$current_version|@preview/typsium:$$new_version|" README.md; \
echo "Version bumped to $$new_version"
bump-patch:
@current_version=$$(grep '^version' typst.toml | awk -F ' = ' '{print $$2}' | tr -d '"'); \
new_version=$$(echo $$current_version | awk -F. '{printf "%d.%d.%d", $$1, $$2, $$3+1}'); \
sed -i '' "s|^version = .*|version = \"$$new_version\"|" typst.toml; \
sed -i '' "s|@preview/typsium:$$current_version|@preview/typsium:$$new_version|" README.md; \
echo "Version bumped to $$new_version"
56 changes: 46 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,56 @@
[![MIT License](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Typsium/typsium/blob/main/LICENSE)
![User Manual](https://img.shields.io/badge/manual-.pdf-purple)

# Typst Chemical Formula Package
# Write beautiful chemical formulas and reactions with Typsium
## Usage
```typst
#import "@preview/typsium:0.3.0":*
```
Enter your chemical formula or reaction into the `#ce"` method like this:
```typst
#ce("[Cu(H2O)4]^2+ + 4NH3 -> [Cu(NH3)4]^2+ + 4H2O")
```
![result](https://raw.githubusercontent.com/Typsium/typsium/main/tests/README-graphic1/ref/1.png)

A Typst package for typesetting chemical formulas, currently working on inorganic.
You can also embed any kind of content into your chemical reactions like by using square brackets instead of a passing in a string. This will also apply any styling to the reaction.

- Typeset chemical formulas with ease
- Reactions and equations, including reversible reactions
- Support for complex reaction conditions (e.g. temperature (T=), pressure (P=), etc.)
> **Warning:** Currently, brackets inside another bracket will not be parsed correctly.

## Usage
```typst
#ce[...]
```

![result2](https://raw.githubusercontent.com/Typsium/typsium/main/tests/README-graphic1/ref/1.png)

There are many different kinds of arrows to choose from.
```typst
#ce[->]\
#ce[=>]\
#ce[<=>]\
#ce[<=]\
#ce("<->")\
#ce("<-")\
```

And you can add additional arguments to them (such as the top or bottom text) by adding square brackets.

```typst
#ce("->[top text][bottom text]")
```

The molecule parsing is flexible and allows many different ways of writing, so you can just copy paste in your formulas and they will probably work. Oxidation numbers can be added like this`^^`, radicals can be added like this`.` and hydration groups can be added like this`*`.

To use Typsium, you need to include the package in your document:
// update to newest typsium usage, add "#import "@preview/typsium:0.3.0": ce" when releasing 0.3.0
```typst
#ce("[Cu(H2O)4] 2+ + 4NH3 -> [Cu(NH3)4] 2+ + 4H2O")
//examples
```

You can use many kinds of brackets. they will auto scale by default, but you can disable it with a show rule.
```typst
//brackets examples and grow-brackets show rule
```
Inline formulas often need to be a bit more compact, for this purpose there is an `affect-layout` rule, which can be toggled on and off for each part of the reaction separately.
```typst
//brackets examples
```

![result](https://raw.githubusercontent.com/Typsium/typsium/main/tests/README-graphic1/ref/formula-parser.svg)
You can use Typsium inside other packages and the styling will be consistent across the entire document.
253 changes: 0 additions & 253 deletions src/data-model.typ

This file was deleted.

Loading
Loading