# Unicode characters in Julia Markdown not exported to pdf

**URL:** <https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528>\
**Category:** New to Julia\
**Tags:** markdown, weave, julia-markdown\
**Created:** [February 21, 2024, 4:46pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528 "2024-02-21T16:46:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nvah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nvah/32/207191_2.png) [@nvah](https://discourse.julialang.org/u/nvah)\
**Post date:** [February 21, 2024, 4:46pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/1 "2024-02-21T16:46:01Z")

</div>

Hi there,

I’m relatively new to Julia and I am working in VS Code on a Mac OS. When I try to export my .jmd file which contains greek letters (\alpha, \varepsilon etc.), I get the following error message:

_Info: Weaving chunk 1 from line 10_  
_└ progress = 0.0_  
_┌ Info: Weaved all chunks_  
_└ progress = 1_  
_[WARNING] Missing character: There is no α (U+03B1) (U+03B1) in font [lmmono12-regular]:!_  
_[WARNING] Missing character: There is no μ (U+03BC) (U+03BC) in font [lmmono12-regular]:!_  
_[WARNING] Missing character: There is no ε (U+03B5) (U+03B5) in font [lmmono12-regular]:!_  
_[Info: Weaved to …]_

This is the example .jmd file for which I get the error:

```julia-auto
---
title: Test title

weave_options:
    doctype: pandoc2pdf
---

```

# Test

```julia
α = 2;
μ = 3;
ε = 4;

```

I export it to pdf by using Weave (I run `weave("filename.jmd')` in Julia terminal in VS Code). The pdf I get displays my code chunk as:

 ![Screenshot 2024-02-21 at 16.45.26](https://global.discourse-cdn.com/julialang/original/3X/3/5/3542bce2cee7602c71193a15d8a40df895cfbe65.png)

I’ve tried including a template .tex file and using `minted` but the output was the same regardless.

```julia-auto
---
title: Test title

weave_options:
    doctype: pandoc2pdf # I also tried it with pandoc and md2tex, neither worked
    template: template.tex
    minted: true
---

```

My `template.tex` file is as follows:

```julia-auto
\documentclass{article}

\usepackage{fontspec}

\usepackage{polyglossia}

\usepackage{minted}

\usepackage{unicode-math}

\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase]

\begin{document}

$body$

\end{document}

```

How can I remedy this? I’ve tried quite a few workarounds suggested [here](https://discourse.julialang.org/t/typesetting-julia-code-in-latex-documents-unicode/10176), but nothing seems to have worked.

Thanks!

---

<div class="post-metadata">

**Author:** ![mnemnion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mnemnion/32/206596_2.png) [@mnemnion](https://discourse.julialang.org/u/mnemnion)\
**Post date:** [February 21, 2024, 5:46pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/2 "2024-02-21T17:46:31Z")

</div>

> [@nvah](#):
>
> How can I remedy this?

Your errors suggest that the font doesn’t have the characters you need. I’d start with trying a font which does.

I’m sure there’s a way to define fallback fonts, so that the characters available in your main font render in that face, and the ones which aren’t come from the fallback. I don’t happen to know what that way is, however.

---

<div class="post-metadata">

**Author:** ![nvah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nvah/32/207191_2.png) [@nvah](https://discourse.julialang.org/u/nvah)\
**Post date:** [February 21, 2024, 8:30pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/3 "2024-02-21T20:30:03Z")

</div>

Thanks for responding!

My understanding of the problem is that the issue comes from my LaTeX engine and Pandoc not being able to print the characters I need. This is only a problem when the characters are inside code chunks, and \alpha is exported into a pdf normally when it’s outside a code chunk.

I’m not sure whether this fallback font should be specified in my LaTeX compiler, in VS Code or somewhere else.

---

<div class="post-metadata">

**Author:** ![dylanxyz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dylanxyz/32/36646_2.png) [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Post date:** [February 21, 2024, 8:44pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/4 "2024-02-21T20:44:03Z")

</div>

I don’t know much about LaTeX, but perhaps the font used in code blocks is different from the normal font of the document, because usually code is shown with a monospace font. Maybe, the font your LaTeX environment uses for code blocks does not support these characters?

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [February 21, 2024, 9:01pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/5 "2024-02-21T21:01:25Z")

</div>

There is [GitHub - cormullion/juliamono: repository for JuliaMono, a monospaced font with reasonable Unicode support.](https://github.com/cormullion/juliamono) which should support all these symbols

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [February 21, 2024, 10:48pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/6 "2024-02-21T22:48:03Z")

</div>

This isn’t strictly speaking a Julia problem, or with any Julia package. Nor for VS Code.

I seem to have confirmed (as I suspected, still wanted to help) it’s a `pandoc` problem (or as explained simply using a different font and/or fallback the likely solution; how? potentially though by telling Weave):

> <https://stackoverflow.com/questions/65177985/pandoc-markdown-to-pdf-fixing-missing-character-warnings>

I started looking if Weave.jl produced the error, i.e. if it’s part if its error messages, but I could only support it running pandoc, and thus indirectly it produces a warnining (as could have happened in R and other ecosystems):

> <https://github.com/JunoLab/Weave.jl/pull/380>
>
> Similar to #379 except it is now based on the new \`master\` branch.
> 
> A net red…uction in lines of code while adding functionality. ;)
> 
> This PR also fixes an issue in the latex formats where unicode was not escaped in output chunks.
> (Something similar should be done for \`Pandoc\` since it reports
> \`\`\`
> julia\> weave("FIR\_design.jmd"; doctype="pandoc2pdf", cache=:refresh, keep\_unicode=false)
> \[WARNING\] Missing character: There is no π (U+03C0) in font \[lmmono12-regular\]:!
> \[WARNING\] Missing character: There is no ⋮ (U+22EE) in font \[lmmono12-regular\]:!
> \[WARNING\] Missing character: There is no ⋮ (U+22EE) in font \[lmmono12-regular\]:!
> \[ Info: Weaved to /home/jonas/.julia/dev/Weave/examples/FIR\_design.pdf
> "/home/jonas/.julia/dev/Weave/examples/FIR\_design.pdf"
> \`\`\`

---

<div class="post-metadata">

**Author:** ![nvah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nvah/32/207191_2.png) [@nvah](https://discourse.julialang.org/u/nvah)\
**Post date:** [February 21, 2024, 11:20pm UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/7 "2024-02-21T23:20:04Z")

</div>

Thank you for your replies.

I’ve only used RMarkdown before and I have not dealt with issues with Pandoc before. From my own testing attempts, I could not get Weave to read in any `header_includes` text and my test output was indifferent to solutions suggested [here](https://tex.stackexchange.com/questions/139139/adding-headers-and-footers-using-pandoc)

Could you please explain how I could implement any of the solutions suggested in the links in the replies above into Julia Markdown files?

Would this mean running multiple commands in the Terminal, all in order to get a `pdf` out of my `.jmd` file? Would I still be able to continue using Weave or would it have to be combined with running some Pandoc lines in the terminal?

Apologies if these seem like very basic questions, this type of pdf exporting is quite new to me.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [February 22, 2024, 8:42am UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/8 "2024-02-22T08:42:18Z")

</div>

One thing I noticed was that your error said:

```plaintext
There is no α (U+03B1) (U+03B1) in font
 [lmmono12-regular]:!

```

and yet you had asked for

```plaintext
\setmonofont{DejaVu Sans Mono}

```

`lmmono12-regular` is the Latin Modern Mono font; whatever its other virtues, it doesn’t have any lower-case greek glyphs, so it’s not a good choice for you.

But why was it chosen? My guess is that the `\setmonofont` request didn’t actually work, for some reason. I think the syntax looks right… I don’t know how font-finding works in this particular environment.

You can specify the exact name of a font file on your system, rather than rely on the font-matching process. For example:

```plaintext
\setmonofont{DejaVuSansMono.ttf}

```

In my own very limited use of LaTeX I used this snippet:

```plaintext
\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage[utf8]{inputenc}
\usepackage{minted}

\setmonofont{JuliaMono-Regular.ttf}[
    Path = /Users/me/Library/Fonts/,
    Contextuals = Alternate,
    CharacterVariant=1,
    Scale = MatchLowercase,
    BoldFont = JuliaMono-Bold.ttf
]

```

which points directly to the font I wanted to test, and chooses the various OpenType options that are available.

I also noticed that `weave()` has an option `keep_unicode`:

```plaintext
* `keep_unicode::Bool = false`: If `true`, do not 
convert unicode characters to their respective 
latex representation. This is especially useful 
if a font and tex-engine with support for 
unicode characters are used

```

I don’t understand this, but perhaps Weave/LaTeX users do…

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [February 22, 2024, 8:46am UTC](https://discourse.julialang.org/t/unicode-characters-in-julia-markdown-not-exported-to-pdf/110528/9 "2024-02-22T08:46:25Z")

</div>

In markdown, you can use

````md
header-includes:
- |
  ```{=latex}
  \setmonofont[Path=./]{Hack-Regular.ttf}

````

```julia

in the header so that the latex convertion will add the correct line to the latex header. Then simply add the font file to your repository.

ps: the forum is not rendering what i meant correctly, take a look at the code of my message.
```
