1

I have some strings to print using PythonTex.

With strings in english, no problem. E.g., I can use string like "a string of char printed using python" and it works

\pyc{print("a string of char printed using python")}

However, when I want to print french text with accents such as "une chaîne de caractères imprimée en utilisant python" it doesn't work at all!

\pyc{print("une chaîne de caractères imprimée en utilisant python")}

So, how I do that? This work :

\pyc{print(r"une cha\^ine de caract\`eres imprim\'ee en utilisant python")}

but is not very friendly!

Thanks you in advance if someone knows how to do and help me.

Here is a MWE to see the problem:

% !TeX encoding = UTF-8
\documentclass[11pt,a4paper]{book}
\usepackage{pythontex}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, frenchb]{babel}

\begin{document}

  With english, no problem, I can use string 
like \verb|"a string of char printed using python"|:

  \pyc{print("a string of char printed using python")}

  However, I want to print french text with accents 
such as \verb|"une chaîne de caractères imprimée en utilisant python"| 
but this doesn't work and blocks like that raises an error:

   \pyc{print("une chaîne de caractères imprimée en utilisant python")}

How I do that?

This work :
   \pyc{print(r"une cha\^ine de caract\`eres imprim\'ee en utilisant python")}
but is not very friendly!

\end{document}
The error message is 
This is PythonTeX 0.15

----  Messages for py:default:default  ----
* PythonTeX notice
    1 message(s) could not be classified
    Interpreted as errors, based on the return code(s)
  Traceback (most recent call last):
* PythonTeX stderr - unknown on line 19:
    File "/py_default_default.py", line 67, in 


--------------------------------------------------
PythonTeX:  essai - 1 error(s), 0 warning(s)

closed as off-topic by Stefan Pinnow, Jesse, Zarko, Jagath, Paul Gaborit Aug 17 '16 at 15:02

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Sorry, I am stupid! This is a python problem. Just need to use : \pyc{print(u"une chaîne de caractères imprimée en utilisant python")} with the "u" – Christian Fernandez Aug 17 '16 at 14:23
  • 4
    I'm voting to close this question as off-topic because it was solved by the OP himself (see comment) – Stefan Pinnow Aug 17 '16 at 14:33

Browse other questions tagged or ask your own question.