文档未显示图表列表(LaTeX)

文档未显示图表列表(LaTeX)

LaTeX我遇到了无法显示List of figures和的问题List of Listings。我不知道问题出在哪里。

我正在使用 TeXstudio,代码定义如下:

\usepackage{acl2013}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx}
\usepackage{float}

\begin{document}

\begin{lstlisting}[caption={Testcode is here}\label{lst:Testcode is here},frame=single] 
//here is the code
\end{lstlisting}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\textwidth]{pic1.jpg}
    \caption{That is a pic}
    \label{fig: That is a pic}
\end{figure}

\listoffigures

\lstlistoflistings

\end{document}

两个列表都是空的。有人能告诉我问题出在哪里吗?

编辑:这是我的文件列表的内容:

*File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size11.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
 acl2013.sty    
inputenc.sty    2008/03/30 v1.1d Input encoding file
    utf8.def    2008/04/05 v1.1m UTF-8 support for inputenc
   t1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  ot1enc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
  omsenc.dfu    2008/04/05 v1.1m UTF-8 support for inputenc
   babel.sty    2008/07/08 v3.8m The Babel package
 bblopts.cfg    2006/07/31 v1.0 MiKTeX 'babel' configuration
 english.ldf    2012/08/20 v3.3p English support from the babel system
 fontenc.sty
   t1enc.def    2005/09/27 v1.99g Standard LaTeX file
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2007/01/18 v1.5 graphics configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
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)
   times.sty    2005/04/12 PSNFSS-v9.2a (SPQR) 
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
latexsym.sty    1998/08/17 v2.2e Standard LaTeX package (lasy symbols)
listings.sty    2015/06/04 1.6 (Carsten Heinz)
 lstmisc.sty    2015/06/04 1.6 (Carsten Heinz)
listings.cfg    2015/06/04 1.6 listings configuration
 caption.sty    2015/09/17 v3.3-111 Customizing captions (AR)
caption3.sty    2015/09/20 v1.7-115 caption3 kernel (AR)
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
   t1ptm.fd    2001/06/04 font definitions for T1/ptm.
supp-pdf.mkii
   ulasy.fd    1998/08/17 v2.2e LaTeX symbol font definitions
   t1pcr.fd    2001/06/04 font definitions for T1/pcr.
  omsptm.fd    
attacheddev.jpg    Graphic file (type jpg)
buildapp.jpg    Graphic file (type jpg)
welcomeapp.jpg    Graphic file (type jpg)
 devmenu.jpg    Graphic file (type jpg)
 content.jpg    Graphic file (type jpg)
 acl2013.bbl
 ***********

答案1

缺失的根源List of...在于,该acl2013包确实使用了以下几行

% We're never going to need a table of contents, so just flush it to
% save space --- suggested by drstrip@sandia-2
\def\addcontentsline#1#2#3{}

\addcontentsline不执行任何操作,并且没有任何变化可以写入.lof.lol等。

这段effective代码很烦人,但在加载之前存储旧定义acl2013并在加载后恢复可以解决问题

\let\origaddcontentsline\addcontentsline
\usepackage{acl2013}
\let\addcontentsline\origaddcontentsline

这是 MWE

\documentclass{article}
\let\origaddcontentsline\addcontentsline
\usepackage{acl2013}
\let\addcontentsline\origaddcontentsline
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{listings}
\usepackage{color}
\usepackage[demo]{graphicx}
\usepackage{float}

\begin{document}

\begin{lstlisting}[caption={Testcode is here}\label{lst:Testcode is here},frame=single] 
//here is the code
\end{lstlisting}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\textwidth]{pic1.jpg}
    \caption{That is a pic}
    \label{fig: That is a pic}
\end{figure}

\listoffigures

\lstlistoflistings

\end{document}

更新

\documentclass{article}
\let\origaddcontentsline\addcontentsline
\usepackage{acl2013}
\let\addcontentsline\origaddcontentsline
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{listings}
\usepackage{xcolor}
\usepackage[demo]{graphicx}
\usepackage{float}

\usepackage{chngcntr}
\counterwithin{figure}{section}  % Adds figure numbering 1.1, 1.2, ..., 2.1 etc. 
\AtBeginDocument{%
\counterwithin{lstlisting}{section}  % Adds figure numbering 1.1, 1.2, ..., 2.1 etc. 
}

\begin{document}

\section{My first section}
\begin{lstlisting}[caption={Testcode is here}\label{lst:Testcode is here},frame=single] 
//here is the code
\end{lstlisting}

\begin{figure}[H]
    \centering
    \includegraphics[width=0.5\textwidth]{pic1.jpg}
    \caption{That is a pic}
    \label{fig: That is a pic}
\end{figure}


\listoffigures

\lstlistoflistings

\end{document}

答案2

您必须运行该文档两次。但是,如果您不希望图像四处浮动,请使用包caption和。\captionof

\listfiles
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage{listings}
\usepackage{caption}
\begin{document}

\begin{lstlisting}[caption={Testcode is here}\label{lst:Testcode is here},frame=single] 
    //here is the code
\end{lstlisting}

\begin{center}
\includegraphics[width=0.5\textwidth]{pic1.jpg}
\captionof{figure}{That is a pic}\label{fig: That is a pic}
\end{center}

\listoffigures
\lstlistoflistings
\end{document}

在此处输入图片描述

文件列表:

 *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
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
graphics.sty    2016/01/03 v1.0q Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
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)
listings.sty    2015/06/04 1.6 (Carsten Heinz)
 lstmisc.sty    2015/06/04 1.6 (Carsten Heinz)
listings.cfg    2015/06/04 1.6 listings configuration
 caption.sty    2016/02/02 v3.3-136 Customizing captions (AR)
caption3.sty    2016/02/02 v1.7-136 caption3 kernel (AR)
supp-pdf.mkii
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
luatex-loader.sty    2010/03/09 v0.4 Lua module loader (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live

相关内容