I just tried using this https://tex.stackexchange.com/a/83883/143861 for syntax highlighting Python in overleaf
\documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} % Default fixed font does not support bold face \DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold \DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12} % for normal % Custom colors \usepackage{color} \definecolor{deepblue}{rgb}{0,0,0.5} \definecolor{deepred}{rgb}{0.6,0,0} \definecolor{deepgreen}{rgb}{0,0.5,0} \usepackage{listings} % Python style for highlighting \newcommand\pythonstyle{\lstset{ language=Python, basicstyle=\ttm, morekeywords={self}, % Add keywords here keywordstyle=\ttb\color{deepblue}, emph={MyClass,__init__}, % Custom highlighting emphstyle=\ttb\color{deepred}, % Custom highlighting style stringstyle=\color{deepgreen}, frame=tb, % Any extra options here showstringspaces=false }} % Python environment \lstnewenvironment{python}[1][] { \pythonstyle \lstset{#1} } {} % Python for external files \newcommand\pythonexternal[2][]{{ \pythonstyle \lstinputlisting[#1]{#2}}} % Python for inline \newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
A Mu µ in the Python environment won't render
\begin{document}
\begin{python}
µ = 5
\end{python}
\end{document}
Due to this error:
Package inputenc Error: Invalid UTF-8 byte "B5.
It renders outside of the python environment.
How can I render a mu inside of a syntax-highlighted Python code block?