I have the following:


%% Language and font encodings
\usepackage[greek, english]{babel}

\title{Your Paper}


blah blah 


% Ελληνικά (Greek) <----- 
Dt = 0.0001;
t = 2+Dt:Dt:100;

% Comment
x = (1/3)*exp(-2*(t-2));

% Comment
x_sq = x.^2;

% Comment
result = Dt * sum(x_sq)
Ελληνικά - \textlatin{This works well, this should appear in the first comment line inside verbatim}.

First of all, I am using PDFLatex. The problem is when I compile this code, the first comment inside verbatim environment appears in latin characters, not in Greek. Is there any way to overcome this?

Thank you in advance.

  • 2
    Welcome to TeX.SX! Why don't you simply use your language? As there is no line breaking/hyphenation within verbatim anyway you won't notice a difference… – TeXnician Jan 4 at 12:20
  • 1
    Welcome to TeX.Stackexchange! Do you face any specific problem? Otherwise just write in whatever language you want. – user36296 Jan 4 at 12:21
  • My problem is that since the text outside verbatim is in Greek (to be more specific), before I use \begin{verbaitm}, I set the language to english to be able to write the code above. However, verbatim environment turns my %Comments written in Greek to english characters. – GKH Jan 4 at 12:59
  • What engine do you use? (pdftex, xetex, luatex). Please edit your question and add a MWE. – David Purton Jan 4 at 13:43
  • Does tex.stackexchange.com/a/428233/4427 help? – egreg Jan 4 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.