![在 verbatim 环境中更改语言](https://linux22.com/image/388576/%E5%9C%A8%20verbatim%20%E7%8E%AF%E5%A2%83%E4%B8%AD%E6%9B%B4%E6%94%B9%E8%AF%AD%E8%A8%80.png)
我有以下内容:
\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}
首先,我使用的是 PDFLatex。问题是,当我编译此代码时,verbatim 环境中的第一个注释以拉丁字符显示,而不是希腊语。有什么方法可以解决这个问题吗?
先感谢您。