Issue
I'm using Julia in a jupyter notebook
.
I want to generate a pdf for the results of my work. However, when generating the pdf, the λ
of the mathematical expression λ=3
is lost so that the output in the pdf is =3
.
Here is the jupyter notebook code
In[1]: λ=3
Out[1]: 3
Here is the pdf generated with the jupyter notebook
In[1]: =3
Out[1]: 3
This is not the case in with the pdf generated with nteract
where the expression λ=3
is fully printed out. However the overall appearance of the pdf generated with nteract
is not as nice as the pdf generated with jupyter notebook
.
Here is printed pdf generated with nteract
(looks exactly the same as the code itself):
In[1]: λ=3
Out[1]: 3
Can somebody know how to print such character with jupyter notebook
?
Many thanks in advance
Solution
The issue is related to how Jupyter itself generates and compiles the latex file. Jupyter, by default, compiles the file with xelatex
to support Unicode. My guess is, however, xelatex
requires some configurations in the files and Jupyter does not generate the file that works out of the box with plain xelatex
command.
You can change the configuration of Jupyter to compile latex file generated with pdflatex
or latex
command.
Solution:
Find your Jupyter configuration directory(i.e. output of jupyter --config-dir
, on Linux usually ~/.jupyter
. To find out which jupyter IJulia uses run using IJulia; IJulia.jupyter
then find out the config directory of that jupyter)
Create the file jupyter_notebook_config.py
in this directory if there is not one, already.
Put the following line of code at the end of this file and save it:
c.PDFExporter.latex_command = ['pdflatex', '{filename}']
Then you can export the PDF file using the notebook, as usual. The characters should appear, just right. This should work provided that pdflatex
command is found in your shell.
If you do not have pdflatex
but have latex
you can also use the following line instead of the code above:
c.PDFExporter.latex_command = ['latex', '--output-format=pdf', '{filename}']
If you are not able to change the configuration of Jupyter, download the latex file and compile it with the command latex --output-format=pdf filename.tex
.
Hope it works!
Answered By - hckr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.