Problem with UTF-8 in Listings not beingsolved by standard answer











up vote
0
down vote

favorite












I'm using TeXstudio and pdfLaTeX. I'm trying to use the listings package to add some Matlab source code to my document. However, I'm having trouble with some portuguese letters used in the code (graphics captions, actually).



The common answer to this known encoding problem is shown here and here. However, even after adding the lstset{literate=} with the correct list, the problem persists. I verified that the problematic letters and indeed in the list to be substituted, but no change.



The lstset and the lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/main.m} I'm calling to add the code are in different files, but that was not a problem for any other package. I also verified that I can include code without any special characters.



What could be causing this problem and what would be a fix or an workaround?



Thanks for any help



EDIT for sample code:
This part is the one being used to substitute letters in the listings.



lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{«}{{guillemotleft}}1 {»}{{guillemotright}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}


This is the line calling listing of the source code



lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/plot_bf_compare_in_out.m}  


Specifically, the section of Matlab code throwing the error is



title("Comparação entre áudio antes e depois do beamformer");


EDIT 2: Since the complete text I am working is spread across multriple files and folders, I recreated the minimum document with everything that seems relevant to this problem and throws the same error. OneDrive download link here with the files.



EDIT 3:
Compilable LaTeX code



documentclass[%twoside,                   % Impressão em frente e verso
oneside, % Impressão apenas frente
]{utfpr-abntex2}


usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{booktabs}
usepackage{color, colortbl}
usepackage{float}
usepackage{graphicx}
usepackage{icomma}
usepackage{indentfirst}
usepackage{microtype}
usepackage{multirow, array}
usepackage{subeqnarray}
usepackage{lastpage}
usepackage{pdfpages}
usepackage{verbatim}
usepackage{amsfonts, amssymb, amsmath}
usepackage[algoruled, portuguese]{algorithm2e}
usepackage{times}
usepackage[bottom]{footmisc}
usepackage{ae, aecompl}
usepackage{latexsym}
usepackage{lscape}
usepackage{picinpar}
usepackage{scalefnt}
usepackage{upgreek}
usepackage{listings}

% Parte utilizada para que códigos fonte possam conter caracteres em português
lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}

begin{document}

lstinputlisting[language=Matlab]{plot_bf_compare_in_out.m}

end{document}


Sample of problematic source code file (.m):



figure;
title("Comparação entre áudio antes e depois do beamformer");









share|improve this question









New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
    – Alan Munn
    Nov 24 at 3:28












  • As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
    – Joseph
    Nov 24 at 17:02










  • XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
    – L. Farinha
    Nov 24 at 19:02






  • 1




    Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
    – Alan Munn
    Nov 24 at 19:19








  • 1




    No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
    – Alan Munn
    Nov 24 at 20:53

















up vote
0
down vote

favorite












I'm using TeXstudio and pdfLaTeX. I'm trying to use the listings package to add some Matlab source code to my document. However, I'm having trouble with some portuguese letters used in the code (graphics captions, actually).



The common answer to this known encoding problem is shown here and here. However, even after adding the lstset{literate=} with the correct list, the problem persists. I verified that the problematic letters and indeed in the list to be substituted, but no change.



The lstset and the lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/main.m} I'm calling to add the code are in different files, but that was not a problem for any other package. I also verified that I can include code without any special characters.



What could be causing this problem and what would be a fix or an workaround?



Thanks for any help



EDIT for sample code:
This part is the one being used to substitute letters in the listings.



lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{«}{{guillemotleft}}1 {»}{{guillemotright}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}


This is the line calling listing of the source code



lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/plot_bf_compare_in_out.m}  


Specifically, the section of Matlab code throwing the error is



title("Comparação entre áudio antes e depois do beamformer");


EDIT 2: Since the complete text I am working is spread across multriple files and folders, I recreated the minimum document with everything that seems relevant to this problem and throws the same error. OneDrive download link here with the files.



EDIT 3:
Compilable LaTeX code



documentclass[%twoside,                   % Impressão em frente e verso
oneside, % Impressão apenas frente
]{utfpr-abntex2}


usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{booktabs}
usepackage{color, colortbl}
usepackage{float}
usepackage{graphicx}
usepackage{icomma}
usepackage{indentfirst}
usepackage{microtype}
usepackage{multirow, array}
usepackage{subeqnarray}
usepackage{lastpage}
usepackage{pdfpages}
usepackage{verbatim}
usepackage{amsfonts, amssymb, amsmath}
usepackage[algoruled, portuguese]{algorithm2e}
usepackage{times}
usepackage[bottom]{footmisc}
usepackage{ae, aecompl}
usepackage{latexsym}
usepackage{lscape}
usepackage{picinpar}
usepackage{scalefnt}
usepackage{upgreek}
usepackage{listings}

% Parte utilizada para que códigos fonte possam conter caracteres em português
lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}

begin{document}

lstinputlisting[language=Matlab]{plot_bf_compare_in_out.m}

end{document}


Sample of problematic source code file (.m):



figure;
title("Comparação entre áudio antes e depois do beamformer");









share|improve this question









New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1




    Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
    – Alan Munn
    Nov 24 at 3:28












  • As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
    – Joseph
    Nov 24 at 17:02










  • XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
    – L. Farinha
    Nov 24 at 19:02






  • 1




    Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
    – Alan Munn
    Nov 24 at 19:19








  • 1




    No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
    – Alan Munn
    Nov 24 at 20:53















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm using TeXstudio and pdfLaTeX. I'm trying to use the listings package to add some Matlab source code to my document. However, I'm having trouble with some portuguese letters used in the code (graphics captions, actually).



The common answer to this known encoding problem is shown here and here. However, even after adding the lstset{literate=} with the correct list, the problem persists. I verified that the problematic letters and indeed in the list to be substituted, but no change.



The lstset and the lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/main.m} I'm calling to add the code are in different files, but that was not a problem for any other package. I also verified that I can include code without any special characters.



What could be causing this problem and what would be a fix or an workaround?



Thanks for any help



EDIT for sample code:
This part is the one being used to substitute letters in the listings.



lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{«}{{guillemotleft}}1 {»}{{guillemotright}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}


This is the line calling listing of the source code



lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/plot_bf_compare_in_out.m}  


Specifically, the section of Matlab code throwing the error is



title("Comparação entre áudio antes e depois do beamformer");


EDIT 2: Since the complete text I am working is spread across multriple files and folders, I recreated the minimum document with everything that seems relevant to this problem and throws the same error. OneDrive download link here with the files.



EDIT 3:
Compilable LaTeX code



documentclass[%twoside,                   % Impressão em frente e verso
oneside, % Impressão apenas frente
]{utfpr-abntex2}


usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{booktabs}
usepackage{color, colortbl}
usepackage{float}
usepackage{graphicx}
usepackage{icomma}
usepackage{indentfirst}
usepackage{microtype}
usepackage{multirow, array}
usepackage{subeqnarray}
usepackage{lastpage}
usepackage{pdfpages}
usepackage{verbatim}
usepackage{amsfonts, amssymb, amsmath}
usepackage[algoruled, portuguese]{algorithm2e}
usepackage{times}
usepackage[bottom]{footmisc}
usepackage{ae, aecompl}
usepackage{latexsym}
usepackage{lscape}
usepackage{picinpar}
usepackage{scalefnt}
usepackage{upgreek}
usepackage{listings}

% Parte utilizada para que códigos fonte possam conter caracteres em português
lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}

begin{document}

lstinputlisting[language=Matlab]{plot_bf_compare_in_out.m}

end{document}


Sample of problematic source code file (.m):



figure;
title("Comparação entre áudio antes e depois do beamformer");









share|improve this question









New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm using TeXstudio and pdfLaTeX. I'm trying to use the listings package to add some Matlab source code to my document. However, I'm having trouble with some portuguese letters used in the code (graphics captions, actually).



The common answer to this known encoding problem is shown here and here. However, even after adding the lstset{literate=} with the correct list, the problem persists. I verified that the problematic letters and indeed in the list to be substituted, but no change.



The lstset and the lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/main.m} I'm calling to add the code are in different files, but that was not a problem for any other package. I also verified that I can include code without any special characters.



What could be causing this problem and what would be a fix or an workaround?



Thanks for any help



EDIT for sample code:
This part is the one being used to substitute letters in the listings.



lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{«}{{guillemotleft}}1 {»}{{guillemotright}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}


This is the line calling listing of the source code



lstinputlisting[language=Matlab]{estrutura/dados/algoritmos/plot_bf_compare_in_out.m}  


Specifically, the section of Matlab code throwing the error is



title("Comparação entre áudio antes e depois do beamformer");


EDIT 2: Since the complete text I am working is spread across multriple files and folders, I recreated the minimum document with everything that seems relevant to this problem and throws the same error. OneDrive download link here with the files.



EDIT 3:
Compilable LaTeX code



documentclass[%twoside,                   % Impressão em frente e verso
oneside, % Impressão apenas frente
]{utfpr-abntex2}


usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{nicefrac}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{booktabs}
usepackage{color, colortbl}
usepackage{float}
usepackage{graphicx}
usepackage{icomma}
usepackage{indentfirst}
usepackage{microtype}
usepackage{multirow, array}
usepackage{subeqnarray}
usepackage{lastpage}
usepackage{pdfpages}
usepackage{verbatim}
usepackage{amsfonts, amssymb, amsmath}
usepackage[algoruled, portuguese]{algorithm2e}
usepackage{times}
usepackage[bottom]{footmisc}
usepackage{ae, aecompl}
usepackage{latexsym}
usepackage{lscape}
usepackage{picinpar}
usepackage{scalefnt}
usepackage{upgreek}
usepackage{listings}

% Parte utilizada para que códigos fonte possam conter caracteres em português
lstset{language=Matlab}
lstset{
inputencoding=utf8,
extendedchars=true,
literate=
{á}{{'a}}1 {é}{{'e}}1 {í}{{'i}}1
{ó}{{'o}}1 {ú}{{'u}}1 {Á}{{'A}}1
{É}{{'E}}1 {Í}{{'I}}1 {Ó}{{'O}}1
{Ú}{{'U}}1 {à}{{`a}}1 {è}{{`e}}1
{ì}{{`i}}1 {ò}{{`o}}1 {ù}{{`u}}1
{À}{{`A}}1 {È}{{'E}}1 {Ì}{{`I}}1
{Ò}{{`O}}1 {Ù}{{`U}}1 {ä}{{"a}}1
{ë}{{"e}}1 {ï}{{"i}}1 {ö}{{"o}}1
{ü}{{"u}}1 {Ä}{{"A}}1 {Ë}{{"E}}1
{Ï}{{"I}}1 {Ö}{{"O}}1 {Ü}{{"U}}1
{â}{{^a}}1 {ê}{{^e}}1 {î}{{^i}}1
{ô}{{^o}}1 {û}{{^u}}1 {Â}{{^A}}1
{Ê}{{^E}}1 {Î}{{^I}}1 {Ô}{{^O}}1
{Û}{{^U}}1 {œ}{{oe}}1 {Œ}{{OE}}1
{æ}{{ae}}1 {Æ}{{AE}}1 {ű}{{H{u}}}1
{Ű}{{H{U}}}1 {ő}{{H{o}}}1 {Ő}{{H{O}}}1
{ç}{{c c}}1 {Ç}{{c C}}1 {ø}{{o}}1
{å}{{r a}}1 {Å}{{r A}}1 {£}{{pounds}}1
{ñ}{{~n}}1 {Ñ}{{~N}}1 {¿}{{?`}}1
}

begin{document}

lstinputlisting[language=Matlab]{plot_bf_compare_in_out.m}

end{document}


Sample of problematic source code file (.m):



figure;
title("Comparação entre áudio antes e depois do beamformer");






listings input-encodings






share|improve this question









New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 24 at 21:38





















New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 24 at 1:44









L. Farinha

13




13




New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
    – Alan Munn
    Nov 24 at 3:28












  • As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
    – Joseph
    Nov 24 at 17:02










  • XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
    – L. Farinha
    Nov 24 at 19:02






  • 1




    Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
    – Alan Munn
    Nov 24 at 19:19








  • 1




    No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
    – Alan Munn
    Nov 24 at 20:53
















  • 1




    Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
    – Alan Munn
    Nov 24 at 3:28












  • As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
    – Joseph
    Nov 24 at 17:02










  • XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
    – L. Farinha
    Nov 24 at 19:02






  • 1




    Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
    – Alan Munn
    Nov 24 at 19:19








  • 1




    No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
    – Alan Munn
    Nov 24 at 20:53










1




1




Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
– Alan Munn
Nov 24 at 3:28






Welcome to TeX.se. It will be quite hard to help you without seeing some example code. Can you please edit your question to include a minimal compilable document that reproduces the problem you're having. (Also, the easiest way to deal with UTF-8 listings is to use LuaLaTeX or XeLaTeX instead of pdfLaTeX.)
– Alan Munn
Nov 24 at 3:28














As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
– Joseph
Nov 24 at 17:02




As Alan said, is there any reason not to switch to XeLaTeX or LuaLaTeX?
– Joseph
Nov 24 at 17:02












XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
– L. Farinha
Nov 24 at 19:02




XeLaTeX doesn't throw errors, but just ignores any letter it doesn't know. LuaLaTeX gives the same error.
– L. Farinha
Nov 24 at 19:02




1




1




Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
– Alan Munn
Nov 24 at 19:19






Thanks for the edit, but this isn't compilable code. Can you put it into a document that begins with documentclass{...} and ends with end{document}. And we can't see your actual lstinputlisting file, so please include some of it directly in the document or add a small sample file to the question too.
– Alan Munn
Nov 24 at 19:19






1




1




No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
– Alan Munn
Nov 24 at 20:53






No, we don't need your exact files. You need to show us a small file in your question (not a link) that reproduces the problem.
– Alan Munn
Nov 24 at 20:53












1 Answer
1






active

oldest

votes

















up vote
-1
down vote



accepted










I solved this problem by changing the input encoding from utf8 to latin1 only in the listings. In the end, I got this as the settings for the listings and it worked.



lstset{
language=Matlab,
inputencoding=latin1,
extendedchars=true,
literate=
{é}{{'{e}}}1
{è}{{`{e}}}1
{ê}{{^{e}}}1
{ë}{{¨{e}}}1
{É}{{'{E}}}1
{Ê}{{^{E}}}1
{û}{{^{u}}}1
{ù}{{`{u}}}1
{ú}{{'{u}}}1
{â}{{^{a}}}1
{à}{{`{a}}}1
{á}{{'{a}}}1
{ã}{{~{a}}}1
{Á}{{'{A}}}1
{Â}{{^{A}}}1
{Ã}{{~{A}}}1
{ç}{{c{c}}}1
{Ç}{{c{C}}}1
{õ}{{~{o}}}1
{ó}{{'{o}}}1
{ô}{{^{o}}}1
{Õ}{{~{O}}}1
{Ó}{{'{O}}}1
{Ô}{{^{O}}}1
{î}{{^{i}}}1
{Î}{{^{I}}}1
{í}{{'{i}}}1
{Í}{{~{Í}}}1
}





share|improve this answer








New contributor




L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    L. Farinha is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461507%2fproblem-with-utf-8-in-listings-not-beingsolved-by-standard-answer%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    -1
    down vote



    accepted










    I solved this problem by changing the input encoding from utf8 to latin1 only in the listings. In the end, I got this as the settings for the listings and it worked.



    lstset{
    language=Matlab,
    inputencoding=latin1,
    extendedchars=true,
    literate=
    {é}{{'{e}}}1
    {è}{{`{e}}}1
    {ê}{{^{e}}}1
    {ë}{{¨{e}}}1
    {É}{{'{E}}}1
    {Ê}{{^{E}}}1
    {û}{{^{u}}}1
    {ù}{{`{u}}}1
    {ú}{{'{u}}}1
    {â}{{^{a}}}1
    {à}{{`{a}}}1
    {á}{{'{a}}}1
    {ã}{{~{a}}}1
    {Á}{{'{A}}}1
    {Â}{{^{A}}}1
    {Ã}{{~{A}}}1
    {ç}{{c{c}}}1
    {Ç}{{c{C}}}1
    {õ}{{~{o}}}1
    {ó}{{'{o}}}1
    {ô}{{^{o}}}1
    {Õ}{{~{O}}}1
    {Ó}{{'{O}}}1
    {Ô}{{^{O}}}1
    {î}{{^{i}}}1
    {Î}{{^{I}}}1
    {í}{{'{i}}}1
    {Í}{{~{Í}}}1
    }





    share|improve this answer








    New contributor




    L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      -1
      down vote



      accepted










      I solved this problem by changing the input encoding from utf8 to latin1 only in the listings. In the end, I got this as the settings for the listings and it worked.



      lstset{
      language=Matlab,
      inputencoding=latin1,
      extendedchars=true,
      literate=
      {é}{{'{e}}}1
      {è}{{`{e}}}1
      {ê}{{^{e}}}1
      {ë}{{¨{e}}}1
      {É}{{'{E}}}1
      {Ê}{{^{E}}}1
      {û}{{^{u}}}1
      {ù}{{`{u}}}1
      {ú}{{'{u}}}1
      {â}{{^{a}}}1
      {à}{{`{a}}}1
      {á}{{'{a}}}1
      {ã}{{~{a}}}1
      {Á}{{'{A}}}1
      {Â}{{^{A}}}1
      {Ã}{{~{A}}}1
      {ç}{{c{c}}}1
      {Ç}{{c{C}}}1
      {õ}{{~{o}}}1
      {ó}{{'{o}}}1
      {ô}{{^{o}}}1
      {Õ}{{~{O}}}1
      {Ó}{{'{O}}}1
      {Ô}{{^{O}}}1
      {î}{{^{i}}}1
      {Î}{{^{I}}}1
      {í}{{'{i}}}1
      {Í}{{~{Í}}}1
      }





      share|improve this answer








      New contributor




      L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        up vote
        -1
        down vote



        accepted







        up vote
        -1
        down vote



        accepted






        I solved this problem by changing the input encoding from utf8 to latin1 only in the listings. In the end, I got this as the settings for the listings and it worked.



        lstset{
        language=Matlab,
        inputencoding=latin1,
        extendedchars=true,
        literate=
        {é}{{'{e}}}1
        {è}{{`{e}}}1
        {ê}{{^{e}}}1
        {ë}{{¨{e}}}1
        {É}{{'{E}}}1
        {Ê}{{^{E}}}1
        {û}{{^{u}}}1
        {ù}{{`{u}}}1
        {ú}{{'{u}}}1
        {â}{{^{a}}}1
        {à}{{`{a}}}1
        {á}{{'{a}}}1
        {ã}{{~{a}}}1
        {Á}{{'{A}}}1
        {Â}{{^{A}}}1
        {Ã}{{~{A}}}1
        {ç}{{c{c}}}1
        {Ç}{{c{C}}}1
        {õ}{{~{o}}}1
        {ó}{{'{o}}}1
        {ô}{{^{o}}}1
        {Õ}{{~{O}}}1
        {Ó}{{'{O}}}1
        {Ô}{{^{O}}}1
        {î}{{^{i}}}1
        {Î}{{^{I}}}1
        {í}{{'{i}}}1
        {Í}{{~{Í}}}1
        }





        share|improve this answer








        New contributor




        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I solved this problem by changing the input encoding from utf8 to latin1 only in the listings. In the end, I got this as the settings for the listings and it worked.



        lstset{
        language=Matlab,
        inputencoding=latin1,
        extendedchars=true,
        literate=
        {é}{{'{e}}}1
        {è}{{`{e}}}1
        {ê}{{^{e}}}1
        {ë}{{¨{e}}}1
        {É}{{'{E}}}1
        {Ê}{{^{E}}}1
        {û}{{^{u}}}1
        {ù}{{`{u}}}1
        {ú}{{'{u}}}1
        {â}{{^{a}}}1
        {à}{{`{a}}}1
        {á}{{'{a}}}1
        {ã}{{~{a}}}1
        {Á}{{'{A}}}1
        {Â}{{^{A}}}1
        {Ã}{{~{A}}}1
        {ç}{{c{c}}}1
        {Ç}{{c{C}}}1
        {õ}{{~{o}}}1
        {ó}{{'{o}}}1
        {ô}{{^{o}}}1
        {Õ}{{~{O}}}1
        {Ó}{{'{O}}}1
        {Ô}{{^{O}}}1
        {î}{{^{i}}}1
        {Î}{{^{I}}}1
        {í}{{'{i}}}1
        {Í}{{~{Í}}}1
        }






        share|improve this answer








        New contributor




        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Nov 25 at 13:27









        L. Farinha

        13




        13




        New contributor




        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        L. Farinha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















            L. Farinha is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            L. Farinha is a new contributor. Be nice, and check out our Code of Conduct.













            L. Farinha is a new contributor. Be nice, and check out our Code of Conduct.












            L. Farinha is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461507%2fproblem-with-utf-8-in-listings-not-beingsolved-by-standard-answer%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?