我有这个示例 tex 文件,其中有一行包含一个很长的单词。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{listings}
\lstset{
breaklines=true,
escapechar=@
}
\usepackage[a4paper,left=1cm,right=1cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage[bookmarks]{hyperref}
\hypersetup{
bookmarksnumbered=true,
bookmarksopen=false,
bookmarksopenlevel=1,
colorlinks=true,
pdfstartview=Fit,
pdfpagemode=UseOutlines,
pdfpagelayout=TwoPageRight
}
\title{My Title}
\listfiles
\begin{document}
\pagenumbering{roman}
\maketitle
\tableofcontents
\pagenumbering{arabic}
\newpage
\section{First Section}
\begin{lstlisting}
This is a long line that should haveBeenBrokenAtAnAppropriatePositionWhichDefinetlyExistsButStillFailedToBreakProperly
haveBeenBrokenAtAnAppropriatePositionWhichDefinetlyExistsButStillFailedToBreakProperly
\end{lstlisting}
\end{document}
尽管我使用的是breaklines
我的,lstlisting
但有问题的行并没有中断。长单词绝对可以放在一行中,如最终 PDF 文件中所示。
有没有办法来解决这个问题没有允许在一个单词内断词吗?
更新
根据评论中的要求,我添加了以下内容\listfiles
,这是输出:
*File List*
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
fontenc.sty
t1enc.def 2005/09/27 v1.99g Standard LaTeX file
listings.sty 2002/04/01 1.0 (Carsten Heinz)
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
lstpatch.sty 2002/10/13 1.0i (Carsten Heinz)
lstmisc.sty 2002/04/01 1.0 (Carsten Heinz)
listings.cfg 2015/06/04 1.6 listings configuration
geometry.sty 2010/09/12 v5.6 Page Geometry
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifvtex.sty 2010/03/01 v1.5 Detect VTeX and its facilities (HO)
ifxetex.sty 2010/09/12 v0.6 Provides ifxetex conditional
hyperref.sty 2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty 2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty 2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
hobsub.sty 2012/05/28 v1.13 Construct package bundles (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
intcalc.sty 2007/09/27 v1.1 Expandable calculations with integers (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty 2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty 2012/04/08 v1.3 Expandable calculations on big integers (HO)
bitset.sty 2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty 2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty 2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
hopatch.sty 2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty 2011/01/30 xcolor patch
atveryend.sty 2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty 2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty 2011/10/16 v3.4 Data extraction from label references (HO)
hycolor.sty 2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
auxhook.sty 2011/03/04 v1.3 Hooks for auxiliary files (HO)
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
pd1enc.def 2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg 2002/06/06 v1.2 hyperref configuration of TeXLive
url.sty 2013/09/16 ver 3.4 Verb mode for urls, etc.
hpdftex.def 2012/11/06 v6.83m Hyperref driver for pdfTeX
rerunfilecheck.sty 2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
color.sty 2016/01/03 v1.1b Standard LaTeX Color (DPC)
color.cfg 2007/01/18 v1.5 color configuration of teTeX/TeXLive
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
supp-pdf.mkii
nameref.sty 2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty 2010/12/03 v1.4 Cleanup title references (HO)
sample.out
sample.out
***********
我还在此处上传了所有相关文件:
答案1
(应 OP 要求发表评论……)
这似乎是该软件包的一个旧版本中的错误。问题中显示listings
的输出表明正在使用的和来自 2002 年,以及似乎不再使用的。该软件包有\listfiles
listings.sty
lstmisc.sty
lstpatch.sty
listings
很多版本从那时起,较新的版本就不再有这个错误。
升级listings
软件包可以修复该问题。