0

In Julia programming language, one can type Unicode character such as screenshot

If I want to copy paste a chunk of code in a tex file. What should I do?

Here is an unsuccessfule attempt:

\documentclass[a4paper, 12pt]{book}
\usepackage{verbatim}
\usepackage{unicode-math}
\begin{document}
\begin{verbatim}

Hello world
μ
x
\end{verbatim}
\end{document}

In the output, the $\mu$ does not appear:

enter image description here

Edit Ok I did some research and found this other answer

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pmboxdraw}

\begin{document}

\begin{verbatim}
verbatim { ├ ─ └ }
\end{verbatim}

\end{document}

However, when this is the output I get

enter image description here

Edit 2 I also tried the following code

\documentclass[a4paper, 12pt]{article} \usepackage{fontspec} \setmainfont{Liberation Serif}
\setmonofont{Liberation Mono} 
\usepackage{verbatim}
\begin{document} Hello world 
\newline μ 
\newline Hello world again 
\begin{verbatim} μ x 
\end{verbatim} 
\end{document}

The font "Liberation Serif" cannot be found / The font "Liberation Mono" cannot be found

ecjb
  • 883
  • The easiest is to use XeLaTeX with fontspec and select a font that contains Greek characters (many fonts have those), both for regular text (\setmainfont) and for verbatim (\setmonofont). See https://tex.stackexchange.com/questions/398335/xetex-typewriter-fonts-and-quotes and https://tex.stackexchange.com/questions/228671/writing-greek-in-xelatex-with-the-default-font, I'll vote to close as a duplicate of the 2nd - note that you don't need all the \newfontfamily and polyglossia stuff. – Marijn Jan 05 '20 at 20:00
  • Example with the font Liberation (for Linux), that has Greek (and several other Unicode characters) both in normal serif text and in monospace: \documentclass[a4paper, 12pt]{article} \usepackage{fontspec} \setmainfont{Liberation Serif} \setmonofont{Liberation Mono} \usepackage{verbatim} \begin{document} Hello world \newline μ \newline Hello world again \begin{verbatim} μ x \end{verbatim} \end{document} – Marijn Jan 05 '20 at 20:04
  • Thank you for your comment @Marijn. I tried your code but get The font "Liberation Serif" cannot be found / The font "Liberation Mono" cannot be found Do you know what I should do? – ecjb Jan 05 '20 at 20:10
  • This means that this particular font is not installed on your system, you can choose a different font that you do have installed. On Windows maybe Times New Roman as serif and Courier New as mono font, for example. – Marijn Jan 05 '20 at 20:21
  • Many thanks for your help @Marjin. now the code works. However when trying to implement this on another 200+ pages .tex file, I get the following error message "Fatal Package fontspec Error: The fontspec package requires either XeTeX or LuaTeX. You must change your typesetting engine to ,e.g., "xelatex" or "lualatex" instead of "latex" or "pdflatex". In Texstudio > User command, it is written "pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex" (In order to use the minted package). The question is now definitely another one but do you have a idea? many thanks again! – ecjb Jan 05 '20 at 20:36
  • You can also use XeLaTeX or LuaLaTeX with --shell-escape in order to use minted, there is probably a button for that somewhere (I'm not sure, I don't use TeXstudio) or otherwise you can change the settings in Options > Configure TeXStudio > Commands. – Marijn Jan 05 '20 at 20:39
  • Ok many thanks @Marijn. I'll try to find the solution – ecjb Jan 05 '20 at 20:46
  • 4
  • Thank you for your comment @PhelypeOleinik. I will check this link out. but right now the main problem is using the fontspec package. – ecjb Jan 05 '20 at 21:44

0 Answers0