目前,我的 lstlisting 环境存在问题。每次我尝试将其包含到我的 LaTeX 文档中时,编译器都会卡在“C:/Users/xxxx/AppData/Local/Programs/MiKTeX 2.9/tex/latex/listings/lstlang1.sty“。一个空的 lstlisting 环境将进行编译。例如
\begin{lstlisting}
\end{lstlisting}
目前我尝试在环境中放置一些文本,例如
\begin{lstlisting}
int i = 10;
\end{lstlisting}
或者只有换行符
\begin{lstlisting}
\end{lstlisting}
编译器卡在 lstlang1.sty。我使用了 pdflatex 编译器,但也测试了 LuLaTeX 和 XeLaTeX (MikTeX 2.9)。我的 LaTeX 文件基于以下模板:https://github.com/jreichwald/DHBW_LaTeX_Template
模板还包含一个 lstlisting 示例,此示例的编译过程不会卡住。如果我尝试用我的 config.tex 替换模板 config.tex,编译过程也会卡住。我认为问题出在我的 config.tex 中,但当我从我的 LaTeX 文档中删除 lstlisting 环境时,一切都正常。
有人有想法吗?
谢谢!
配置.tex
% !TEX root = master.tex
% LANGUAGE SETTINGS AND FONT ENCODING
%
\usepackage[ngerman]{babel} % German language
\usepackage[utf8]{inputenc}
\usepackage[german=quotes]{csquotes} % correct quotes using \enquote{}
\usepackage[T1]{fontenc}
% ------ Custom Packages
\usepackage{microtype}% verbesserter Randausgleich
\usepackage[section]{placeins}
\usepackage{longtable}
\usepackage{amsmath}
\usepackage{pdfpages}
\usepackage{manyfoot}
% HYPERREF
%
\usepackage[
hidelinks=true % keine roten Markierungen bei Links
]{hyperref}
% Zwei eigene Befehle zum Setzen von Autor und Titel. Ausserdem werden die PDF-Informationen richtig gesetzt.
\newcommand{\TitelDerArbeit}[1]{\def\DerTitelDerArbeit{#1}\hypersetup{pdftitle={#1}}}
\newcommand{\AutorDerArbeit}[1]{\def\DerAutorDerArbeit{#1}\hypersetup{pdfauthor={#1}}}
\newcommand{\Firma}[1]{\def\DerNameDerFirma{#1}}
\newcommand{\Kurs}[1]{\def\DieKursbezeichnung{#1}}
%\usepackage[table,xcdraw]{xcolor}
% ---- Eigene Counter -----
\newcounter{AB}
\newcounter{A}
\newcounter{AN}
\newcounter{AP}
\newcounter{AU}
\newcounter{HW}
\newcounter{I}
\newcounter{M}
\newcounter{MB}
\newcounter{NW}
\newcounter{O}
\newcounter{P}
\newcounter{PO}
\newcounter{SW}
\newcounter{T}
\newcounter{V}
\newcounter{VE}
\newcounter{W}
\newcounter{footnoteA}
%------------------------------------------
%--------------- Eigene Längen ------------
\newlength{\asdf} %definiere neue länge
\setlength{\asdf}{\textwidth} %setze neue länge auf textbreite
\addtolength{\asdf}{-6\tabcolsep} %subtrahiere -8\cdot textbreite von asdf
%----------Eigene Kommandos ---------------
\newcommand{\kategorieINIT}{
* & Inhalt der Codierten Stelle. & Generallisierung des Inhalts. \\ \hline
}
\newcommand{\kategorie}[3]
{
\stepcounter{#1}
#1.\arabic{#1} & #2 & #3 \\ \hline
}
\newcommand{\teamdesc}[1]{
\multicolumn{3}{|c|}{#1} \\ \hline
}
\newcommand*{\captionsource}[2]{%
\caption[{#1}]{%
#1 \hfill \hspace{\linewidth}%
%\\\hspace{\linewidth}%
\textbf{Quelle:} #2%
}%
}
\newfootnote{A}
\newcommand{\footnoteA}{%
\stepcounter{footnoteA}%
\Footnotemark\thefootnoteA \FootnotetextA{}}
\renewcommand{\thefootnoteA}{\alph{footnoteA}}
%--------------------------------------------
%------- Eigene Umgebungen ------------------
\usepackage{xargs}
\newenvironment{MultiTable}[2][1=no caption,2=noLabel]{
\iffalse
\setcounter{AB}{0}
\setcounter{A}{0}
\setcounter{AN}{0}
\setcounter{AP}{0}
\setcounter{AU}{0}
\setcounter{HW}{0}
\setcounter{I}{0}
\setcounter{M}{0}
\setcounter{MB}{0}
\setcounter{NW}{0}
\setcounter{O}{0}
\setcounter{P}{0}
\setcounter{PO}{0}
\setcounter{SW}{0}
\setcounter{T}{0}
\setcounter{V}{0}
\setcounter{VE}{0}
\setcounter{W}{0}
\fi
\begin{longtable}{|p{.07\asdf}|p{.52\asdf}|p{.41\asdf}|}
\caption{#1} \label{#2} \\
\hline
Code & Wert & Generalisierung \\ \hline
}{
\end{longtable}
}
\newenvironment{descriptionrueck}{
\addmargin{1em}\description
}{
\enddescription
\endaddmargin
}
%------------------------------------------------------------
%-----------------------------------------------------------
\usepackage{filecontents,pdfpages}
\usepackage{formular}
\usepackage[page,titletoc,title,toc]{appendix}
\addto\captionsngerman{%
\renewcommand{\appendixpagename}{\sffamily Anhänge}
\renewcommand{\appendixtocname}{Anhänge}
}
% Correct superscripts
\usepackage{fnpct}
\usepackage{enumerate}
% CALCULATIONS
%
\usepackage{calc} % Used for extra space below footsepline
\usepackage{setspace}
\usepackage{tikz}
% BIBLIOGRAPHY SETTINGS
%
% Uncomment the next three lines for author-year-style with footnotes (Chicago)
\usepackage{enumitem}
\usepackage[numbib]{tocbibind}
\usepackage[autopunct=false, backend=biber, sorting=nty, autocite=footnote, bibstyle=numeric, citestyle=authoryear-ibid, eprint=false,doi=false,isbn=false]{biblatex} %Use Author-Year-Cites with footnotes
\AdaptNoteOpt\footcite\multfootcite %will add separators if footcite is called multiple consecutive times
\AdaptNoteOpt\autocite\multautocite % will add separators if autocite is called multiple consecutive times
\DeclareFieldFormat{url}{\newline\url{#1}}
\DeclareFieldFormat{urldate}{\addcomma\space\bibstring{urlseen}\space#1}
\DefineBibliographyStrings{german}{%
urlseen = {Abruf am},
}
% Uncomment the next line for IEEE-style
% \usepackage[backend=biber, autocite=inline, style=ieee]{biblatex} % Use IEEE-Style (e.g. [1])
% Uncomment the next line for alphabetic style
% \usepackage[backend=biber, autocite=inline, style=alphabetic]{biblatex} % Use alphabetic style (e.g. [TGK12])
% Uncomment the next two lines vor Harvard-Style
%\usepackage[backend=biber, style=apa]{biblatex}
%\DeclareLanguageMapping{german}{german-apa}
\DefineBibliographyStrings{ngerman}{ %Change u.a. to et al. (german only!)
andothers = {{et\,al\adddot}},
}
%%% Uncomment the following lines to support hard URL breaks in bibliography
%\apptocmd{\UrlBreaks}{\do\f\do\m}{}{}
%\setcounter{biburllcpenalty}{9000}% Kleinbuchstaben
%\setcounter{biburlucpenalty}{9000}% Großbuchstaben
\setlength{\bibparsep}{\parskip} %add some space between biblatex entries in the bibliography
\addbibresource{bibliography.bib} %Add file bibliography.bib as biblatex resource
% FOOTNOTES
%
% Count footnotes over chapters
\usepackage{chngcntr}
\counterwithout{footnote}{chapter}
% ACRONYMS
%%%
%%% WICHTIG: Installieren Sie das neueste Acronyms-Paket!!!
%%%
\makeatletter
\usepackage[printonlyused]{acronym}
\@ifpackagelater{acronym}{2015/03/20}
{%
\renewcommand*{\aclabelfont}[1]{\textbf{\textsf{\acsfont{#1}}}}
}%
{%
}%
\makeatother
% LISTINGS
\usepackage{listings} %Format Listings properly
\renewcommand{\lstlistingname}{Quelltext}
\renewcommand{\lstlistlistingname}{Quelltextverzeichnis}
\lstset{numbers=left,
numberstyle=\tiny,
captionpos=b,
basicstyle=\ttfamily\small}
% EXTRA PACKAGES
\usepackage{lipsum} %Blindtext
\usepackage{graphicx} % use various graphics formats
\usepackage[german]{varioref} % nicer references \vref
\usepackage{caption} %better Captions
\usepackage{booktabs} %nicer Tabs
\usepackage[german]{cleveref} %referenz
\usepackage{array}
%\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
% ALGORITHMS
\usepackage{algorithm}
\usepackage{algpseudocode}
\renewcommand{\listalgorithmname}{Algorithmenverzeichnis }
\floatname{algorithm}{Algorithmus}
% FONT SELECTION: Entweder Latin Modern oder Times / Helvetica
\usepackage{lmodern} %Latin modern font
%\usepackage{mathptmx} %Helvetica / Times New Roman fonts (2 lines)
%\usepackage[scaled=.92]{helvet} %Helvetica / Times New Roman fonts (2 lines)
% PAGE HEADER / FOOTER
% Warning: There are some redefinitions throughout the master.tex-file! DON'T CHANGE THESE REDEFINITIONS!
\RequirePackage[automark,headsepline,footsepline]{scrpage2}
\pagestyle{scrheadings}
\renewcommand*{\pnumfont}{\upshape\sffamily}
\renewcommand*{\headfont}{\upshape\sffamily}
\renewcommand*{\footfont}{\upshape\sffamily}
\renewcommand{\chaptermarkformat}{}
\RedeclareSectionCommand[beforeskip=0pt]{chapter}
\crefname{chapter}{Kapitel}{Kapitel}
\crefname{section}{Unterkapitel}{Unterkapitel}
\crefname{subsection}{Unterkapitel}{Unterkapitel}
\clearscrheadfoot
\ifoot[\rule{0pt}{\ht\strutbox+\dp\strutbox}DHBW Mannheim]{\rule{0pt}{\ht\strutbox+\dp\strutbox}DHBW Mannheim}
\ofoot[\rule{0pt}{\ht\strutbox+\dp\strutbox}\pagemark]{\rule{0pt}{\ht\strutbox+\dp\strutbox}\pagemark}
\ohead{\headmark}
答案1
该问题与加载包的顺序错误有关。
\usepackage{hyperref}
\usepackage{varioref}
\usepackage{cleveref}
在这种情况下,顺序应该是这样的:
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
非常感谢来自goLaTeX 论坛