My usual goto for writing pseudocode is the listings package, but unfortunately, I find myself writing a document in my native language (portuguese) and I need to write UTF-8 characters in pseudocode, and listings is not playing along.
Furthermore, I also need to use mathmode.
The code I'm trying to do in specific is this:
\begin{lstlisting}[mathescape=true]
Para todo $B \subseteq N$:
Se as colunas de $A_B$ são linearmente independentes:
Resolver o sistema $A_B x = b$.
Se este tiver solução $x$:
Se $x \geq 0$:
Definir $v \in \mathbb R^n$ de modo a que $v_B = x$ e $v_{N\setminus B} = 0$
Adicionar $v$ à lista de vértices.
\end{lstlisting}
This particular bit of code doesn't work, as I get the following error:
! Package inputenc Error: Unicode char �\expandafter (U+4F1)
(inputenc) not set up for use with LaTeX.
(Though I do need inputenc to typeset UTF-8 characters, and as far as I can tell, it's a listings problem.)
The specific package does not matter, I'm just looking for a way to typeset pseudocode in my native language while still being able to use mathmode.
This also rules out fancyvrb and alltt, as those didn't play along with sub and superscripts.
TIA


à lista à lista(duplicated), the secondà listais printed correctly. I think it's a bug... But using thekeepspacesoption apparently solves the problem temporarily. – Phelype Oleinik Aug 11 '18 at 21:02$v$. If you writeAdicionar v à lista $v$ à lista, the second space disappears. – Phelype Oleinik Aug 11 '18 at 21:09