Hi all, a common problem that I experience is that Obsidian Markdown files, which appear Just Fine:trade_mark:, in which I have used Unicode characters (e.g., , β) cannot export the Unicode characters – appearing as blank space in the output PDF.
Adding --pdf-engine=xelatex (at Google’s AI suggestion – to no effect) to extra Pandoc command-line arguments in the Pandoc Plugin settings
Brainstorming
The crème de la crème of helpful answers would solve my immediate need to export PDF documents using Pandoc Plugin’s function, but also, I would be grateful for any guide that gives a basic understanding of font management on Apple systems, and any relevant manpages from Obsidian’s documentation.
I have Adobe Creative Cloud, and have used it as a total neophyte, to install some fonts that I have used inside Adobe products like Illustrator – but alas, I am basically clueless about how to use these fonts outside of Adobe… admittedly, even that is a bit of a challenge, I’m no expert!
I have no real idea about typesetting or how to use MacLaTeX, I installed it because I was told it’s good for an author to have as an alternative to Adobe Illustrator. I have a basic sense that this “fits” here somehow, but how exactly, I am unsure about.
Conclusion
Any help that you can give me to be able to export Unicode characters in a professional, legible font from my Obsidian Markdown documents is paramount! I will gladly accept – am eager for, even – more fundamental and basic RTFM-style responses that point me in the direction of basic system font management, towards this same end.
Originally, (pdf)LaTeX used its own fonts (not system-installed ones). If you wanted to use a different font, you first had to install it specifically for LaTeX—assuming the font existed in a format compatible with LaTeX.
Fortunately, this has changed with modern LaTeX engines such as XeLaTeX and LuaLaTeX. These engines can use system fonts, including those installed via Creative Cloud. You just need to specify XeLaTeX as the engine and include an appropriate preamble in your LaTeX document, instructing XeLaTeX to use the desired font.
For example, if you want to use DejaVu Sans as the main font in your document (and the Mono version for code), include the following in your LaTeX document:
\setmainfont[]{DejaVu Sans}
\setmonofont[Mapping=tex-ansi]{DejaVu Sans Mono}
So the question is how to instruct Pandoc to insert the appropriate LaTeX commands into the intermediate file.
Fortunately, this is easy too. You can embed the following in the YAML preamble of your note:
---
mainfont: DejaVu Sans
monofont: DejaVu Sans Mono
---
Alternatively, you can pass extra arguments to Pandoc: -V mainfont:"DejaVu Sans"-V monofont:"DejaVu Sans Mono"
Demo
This markdown file:
# Testing DejaVu fonts
## This is a subsection
This is an example or regular text. This is **bold** and this is _italics_.
This is a LaTeX formula: $\sum_{i=0}^\infty x^{-i}$
This is some unicode™ text (β).
## Additional tests
- Unicode Mathematical Operators: ∀ ∁ ∂ ∃ ∄ ∅ ∆ ∇ ∈ ∉ ∊ ∋ ∌ ∮
- Dingbats: ✄ ❶ ❷ ❸ ➀ ➁ ➂
- Number Forms: ⅓ ⅔ ⅕
## Code
```python
# Python Example™
print("╒═════╕")
print("│ αβγ │")
print("╘═════╛"))
```
Great, thank you so much! That really helps. Is there a command-line and/or GUI utility I can use that lists the installed (pdf)LaTeX fonts and (OS X) system fonts?
The only other thing I feel I’m missing, is your strong basic understanding of how these fonts work together. The way you used \setmonofont[Mapping=tex-ansi]{DejaVu Sans Mono} belies my gap of understanding what’s going on “under the hood.” I’d love any insight I might be given into this a bit more, too!
I can’t test on macOS either, but if you have fontconfig installed (brew install fontconfig), fc-list : family will list the system fonts.
macOS GUI alternative: Font Book (/System/Applications/Font Book.app).
Adobe Fonts activated through Creative Cloud live in a private folder and don’t come as loose OTF files, but XeLaTeX will still see them once activated.
To add your own OTF/TTF without touching the system, drop them in ~/Library/Fonts/ (or ~/.local/share/fonts if you rely on fontconfig) and run fc-cache -f. XeLaTeX will pick them up.
There’s no single command that lists pdfLaTeX fonts; luaotfload-tool -l covers Xe/LuaLaTeX, and tlmgr info --list | grep '/fonts/' shows TeX Live font packages
However, pdfLaTeX’s font support is limited and awkward to extend. I’d rather use XeLaTeX (or LuaLaTeX) with OpenType fonts that have solid Unicode coverage. Free families such as DejaVu, Noto, Libertinus, or Fira should be more than enough for exporting Obsidian notes with pandoc—unless your notes mix Latin with CJK or right-to-left scripts.
I need to tell you this – you are an absolute legend. This is all very helpful. I’ve since set up some templates to export PDFs that support the unicode and are formatted for readability – just great, a mix of Adobe & system fonts.