0

I have the following:

\documentclass[a4paper]{article}

%% Language and font encodings
\usepackage[greek, english]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath}

\selectlanguage{english}
\title{Your Paper}
\author{You}

\begin{document}
\maketitle

\begin{abstract}
blah blah 
\end{abstract}

\section{Introduction}

\begin{verbatim}
% Ελληνικά (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)
\end{verbatim}
\selectlanguage{greek}
Ελληνικά - \textlatin{This works well, this should appear in the first comment line inside verbatim}.
\end{document}

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.

GKH
  • 101
  • 3
  • 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 04 '19 at 12:20
  • 1
    Welcome to TeX.Stackexchange! Do you face any specific problem? Otherwise just write in whatever language you want. – samcarter_is_at_topanswers.xyz Jan 04 '19 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 04 '19 at 12:59
  • What engine do you use? (pdftex, xetex, luatex). Please edit your question and add a MWE. – David Purton Jan 04 '19 at 13:43
  • Does https://tex.stackexchange.com/a/428233/4427 help? – egreg Jan 04 '19 at 14:15
  • @egreg, it should but it does not, I get some weird compilation error. Thank you for this, I will try to figure it out using this information. – GKH Jan 04 '19 at 14:30
  • Why are you using iso-8859-7 instead of UTF-8? – egreg Jan 04 '19 at 14:32
  • @egreg, There is no particular reason I guess. I started using it years ago, so I just kept it over the years. Unfortunately, changing it into UTF8 messes up my whole document. – GKH Jan 04 '19 at 14:36
  • @GKH You need to change the document encoding, not just the option to inputenc. – egreg Jan 04 '19 at 14:42
  • @egreg, I thought so. However, it is a compilation of tens of different .tex files and it will take some time. Thank you for your help! I'll post again if I make it work. – GKH Jan 04 '19 at 14:45

0 Answers0