1

I used the code from here to write some java code in beamer that uses the Luebeck theme.

\documentclass[11pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{cprotect}
\usepackage{listings}
\usepackage{color}
\usetikzlibrary{arrows.meta}
\usetheme{Luebeck}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
    language=Java,
    aboveskip=3mm,
    belowskip=3mm,
    showstringspaces=false,
    columns=flexible,
    basicstyle={\small\ttfamily},
    numbers=none,
    numberstyle=\tiny\color{gray},
    keywordstyle=\color{blue},
    commentstyle=\color{dkgreen},
    stringstyle=\color{mauve},
    breaklines=true,
    breakatwhitespace=true,
    tabsize=4
}
\begin{document}
%...
\begin{frame}[fragile]
        \frametitle{Java}
\begin{lstlisting}
// Hello.java
import javax.swing.JApplet;
import java.awt.Graphics;

public class Hello extends JApplet {
    public void paintComponent(Graphics g) {
        g.drawString("Hello, world!", 65, 95);
    }    
}
\end{lstlisting}
\end{frame}
\end{document}

I get the output as below.

Output

The lstlising is inside a fragile frame.
Why are all my tabs replace with ^^I and how do I stop that from happening.

marked as duplicate by user36296 beamer Mar 17 at 19:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • With the information you have provided so far, the issue is not reproducible. Could you therefor please add a minimal working example (MWE) that reproduces the output you get? – leandriis Mar 17 at 17:05
  • 1
    Hmm, I get the desired output. – JouleV Mar 17 at 17:10
  • I tried pasting the MWE alone in a new file and It works perfectly. – BBloggsbott Mar 17 at 17:11
  • @BBloggsbott I think you have some other settings, or some commands that change tab to ^^I for example (though I don't know such commands). – JouleV Mar 17 at 17:12
  • I just noticed that the MWE uses spaces instead of tabs. When I use tabs, I get the ^^Is again. – BBloggsbott Mar 17 at 17:13

Browse other questions tagged or ask your own question.