Hallo zusammen, ich schreibe aktuell meine erste Arbeit mit LaTeX und habe ein Problem bei den CodeListings. Wenn ich das Listing einfüge generiert OverLeaf die Buchstuben "ptm" direkt darüber, obwohl sich diese nirgends in meinem geschriebenen Dokument befinden.

Ich kann leider keine Biler hochladen daher so als Beispiel:

ptm
(hier fängt der Codeblock an)
 1 H i e r i s t Programmcode
(hier endet der Codeblock)
Listing 6.1: example

Minimalbeispiel:

\documentclass[
    paper = a4,
    fontsize = 12pt,
    headinclude = true,
    % start chapters on the right side
    open = right,
    % Use twosided layout? Every chapter starts on the right side, therefore sometimes blank pages are added between chapters.
    twoside = false,
    BCOR = 10mm,
    % add lists and bibliography to table of contents
    toc = listofnumbered,
    toc = bibnumbered,
    % enumerate chapters as x.y instead of x.y.
    numbers = noendperiod
]{scrreprt}

% use some additional package, add your own below if required
\usepackage[a4paper]{geometry}
\usepackage{subcaption}
\usepackage[utf8]{inputenc}
\usepackage{pdfpages}
\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{setspace}
\setstretch{1.5}
\usepackage[nottoc,numbib, notlof]{tocbibind}
\usepackage{float}

\newcommand\frontmatter{%
    \cleardoublepage
    \pagenumbering{roman}}
\newcommand\mainmatter{%
    \cleardoublepage
    \pagenumbering{arabic}}
\newcommand\backmatter{%
    \cleardoublepage
    \pagenumbering{Roman}}

% package for code listings
\usepackage{listings}
% package providing colors (e.g. for syntax highlighting in listings)
\usepackage{xcolor}
% package for german language, change to english if required
\usepackage[ngerman]{babel}
\usepackage[german=quotes]{csquotes}
\usepackage{xpatch}
\usepackage{hyphenat}
% package to set the line spacing
\usepackage{setspace}
% package for hyperlinks (e.g., in the table of contents) and set links to same style as text
\usepackage[hidelinks]{hyperref}
% package to create acronyms
\usepackage[acronym]{glossaries}
% package for pseudocode
\usepackage[german, algochapter, linesnumbered]{algorithm2e}
% package to create diagrams
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric, arrows}
\tikzset{font={\fontsize{10pt}{12}\selectfont}}

%%% additions by ACV
% Citations using APA style with biblatex
\usepackage[style=alphabetic, labelnumber, defernumbers=true, urldate=long, dateabbrev=false,backend=biber,backref=false,maxbibnames=20]{biblatex}
% Biblatex allows multiple bib-files
\addbibresource{bibliography/sources.bib}

% Tables using APA Style
\usepackage{booktabs}

% use microkerning for improved typesetting
\usepackage{microtype}

% include acronyms


% avoid bold caption for algorithms to be consistent with other captions
\SetAlCapSty{}
\SetNlSty{footnotesize}{}{}

% definitions for syntax highlighting in listings environment
% define custom colors for syntax highlighting in code listings
\definecolor{lst_comments}{rgb}{0, 0.75, 0}
\definecolor{lst_linenumbers}{rgb}{0.2, 0.2, 0.2}
\definecolor{lst_keywords}{rgb}{0, 0, 0.75}
\definecolor{lst_strings}{rgb}{0.75, 0, 0}
\definecolor{lst_background}{rgb}{0.97, 0.97, 0.97}

% define style for listings
\lstdefinestyle{msqc_style}{
    backgroundcolor=\color{lst_background},   
    commentstyle=\color{lst_comments},
    keywordstyle=\color{lst_keywords},
    stringstyle=\color{lst_strings},
    % style of the line numbers on the left side
    numberstyle=\tiny\color{lst_linenumbers},
    % use monospace font for code and set size to the size of footnotes
    basicstyle=\rmdefault\footnotesize,
    % xleftmargin=2em,
    % break long lines, if this happens it might be better to manually add a line break at an appropriate place
    breaklines = true,
    % place caption below the listing
    captionpos = b,
    % don't drop spaces to fix alignment and always convert tabs to spaces
    keepspaces = true,
    % place line numbers on the left side
    numbers = left,
    % distance between line numbers and listing
    numbersep = 5pt,
    % don't show special characters for spaces
    showspaces = false,
    % don't show special characters for spaces in strings
    showstringspaces = false,
    % don't show special characters for tabs
    showtabs = false,
    % set size of tab to 4 spaces
    tabsize = 2
}
% set style for the document
\lstset{style=msqc_style}

% set line spacing to 1.5
\onehalfspacing
\makeglossaries

\geometry{a4paper,left=45mm,right=20mm, top=30mm, bottom=3cm}

\begin{document}

    \begin{lstlisting}[language=Java]
    Hier ist Programmcode
\end{lstlisting}

\end{document}

Hat jemand eine Idee, warum das "ptm" über den Codeblock generiert wird?

gefragt 27 Mär, 10:19

Unsii's gravatar image

Unsii
261
Akzeptiert-Rate: 0%

bearbeitet 27 Mär, 11:28

1

Willkommen auf TeXwelt.de! Hier steht nirgendwo "ptm" im Code. Eine Schriftart hat diese Bezeichnung, evtl. wird die durch eine Einstellung geladen, die hier nicht sichtbar ist. Poste doch einmal ein Minimalbeispiel, das übersetzbar ist, so kann man es nachvollziehen. Du kannst Deine Frage hier editieren.

(27 Mär, 11:14) stefan ♦♦
1

Hallo Stefan, danke dir erstmal für die Rückmeldung. Ich habe mal ein Minimalbeispiel beigefügt. :)

(27 Mär, 11:29) Unsii

@Unsii Perfekt, dann kann ich eine Lösung unten schreiben. :-)

(27 Mär, 11:39) stefan ♦♦

Das Problem ist hier

basicstyle=\rmdefault\footnotesize

Laut Doku ist die Option evtl. problematisch bei nicht-trivialen Stilen. Wenn Du einfach basicstyle=\footnotesize schreibst, funktioniert es normal.

Permanenter link

beantwortet 27 Mär, 11:40

stefan's gravatar image

stefan ♦♦
18.1k153048
Akzeptiert-Rate: 48%

Super, das ist die Lösung. Vielen Dank für die schnelle Antwort. :)

(27 Mär, 11:43) Unsii
Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×74
×22
×2

gestellte Frage: 27 Mär, 10:19

Frage wurde gesehen: 534 Mal

zuletzt geändert: 27 Mär, 11:43