I want my Java code to be typeset in a monospaced font, so I am using the verbatim
environment. LaTeX commands are highlighted in Eclipse, but as soon as I use the verbatim
environment everything inside and the color of the environment itself becomes gray.
\begin{verbatim}
public class main {
public static void main (string[] args){
for(int i = 0; i < arg.length; i ++){
System.out.println(args[i]);
}
}
};
\end{verbatim}
I'm using the verbatim
and alltt
packages.
Update 1.
MWE.
\documentclass[xcolor=dvipsnames]{beamer}
\mode<presentation>
{
\usetheme{CambridgeUS}
\setbeamercovered{transparent}
}
% Поддержка русского языка
\RequirePackage[utf8]{inputenc}
\RequirePackage[T2A]{fontenc}
\RequirePackage[russian]{babel}
\RequirePackage{amsfonts}
\usepackage{algorithmic}
\usepackage{mathptmx}
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
\usepackage{pst-node}
\usepackage{pst-tree}
\usepackage{auto-pst-pdf}
\usepackage{color}
\usepackage{colortbl}
\usepackage{pstricks}
\usepackage{verbatim}
\usepackage{alltt}
\usepackage{listings}
\usepackage{animate}
\usepackage{multimedia}
\title{Title}
\author{Name}
\institute{}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{Outline}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}{Классификация по поколениям}
\begin{itemize}
\item Третьего поколения (высокоуровневые языки) - последовательность
высокоуровневых конструкций (циклы, условные выражения, классы, интерфейсы,
методы, процедуры, \ldots) \pause
\begin{exampleblock}{Пример}
\begin{centering}
Fortran, C, C++, C\#, Java, Lisp.
\begin{verbatim}
public class main {
public statiс void main (string[] args){
for(int i = 0; i < arg.length; i ++){
System.out.println(args[i]);
}
}
};
\end{verbatim}
\end{centering}
\end{exampleblock}\pause
\item Четвертого поколения (для конкретного применения) -
последовательность инструкций конкретной предметной области \pause
\begin{exampleblock}{Пример}
SQL, Postscript, XML, Mathlab.
\end{exampleblock} \pause
\end{itemize}
\end{frame}
\end{document}
Best Answer
You cannot use any of the verbatim environments, including verbatim itself, just as any of the listing environment without writing,
or any other form of passing the
fragile
flag to the \frame command. If the frame does not include any overlays, i.e., it has only a single slide, it is recommended to write: