latex 中的报告类在编译时会为子图生成错误?仍然会生成错误

latex 中的报告类在编译时会为子图生成错误?仍然会生成错误
\documentclass[12pt, a4paper]{report} % Report class in 11 points
\usepackage[left=1.5in,right=1.5in,top=1.7in,bottom=1.7in]{geometry}
%\usepackage{setspace}
\usepackage[titles]{tocloft}
\usepackage{afterpage}
%\usepackage{sectsty}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{multirow}
\usepackage{array}
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfigure}
%\usepackage{subfig}
\usepackage{color}
\usepackage{lscape}
\usepackage{amsfonts}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{algpseudocode}
\usepackage{algorithm}
%\usepackage{algpseudocode}
\usepackage[english]{babel}
\usepackage{parskip}
\usepackage[export]{adjustbox}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{commath}
%\usepackage{auto-pst-pdf}
%\usepackage{pdfpages}
\usepackage{rotating}
\usepackage{epsfig}
\usepackage{booktabs}
\usepackage{lscape}
\usepackage{float}
%\usepackage{dsfont}
\usepackage{mathtools}
%\usepackage{algorithm}
%\usepackage{algorithmic}
\usepackage{url}
\usepackage{nomencl}

%\usepackage{longtable}
%\usepackage[acronym]{glossaries}

\usepackage{cases}
\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\large\bfseries\centering}%
    {\chaptername~\thechapter}{1ex}{}
     \usepackage{lipsum}

%\allsectionsfont{\usefont{OT1}{times}{bc}{n}\bf\selectfont}
%\onehalfspace
\titlepage
\begin{document}
\begin{figure}[!htp]
 \begin{subfigure}[b]{1\textwidth}
 \centering
       \includegraphics[scale=0.6]{DAPS.eps}
        \caption{DAPS}
        \label{fig:(DAPS)}
    \end{subfigure}

 \begin{subfigure}[b]{1\textwidth}
 \centering
        \includegraphics[scale=0.6]{RTPS.eps}
        \caption{RTPS }
      \label{fig:(RTPS)}
    \end{subfigure}

  \begin{subfigure}[b]{1\textwidth}
  \centering
        \includegraphics[scale=0.6]{ToUS.eps}
        \caption{ToUSP}
\label{fig:(c)}
    \end{subfigure}
\caption{Price}
\label{PDR}
\end{figure}
\titleformat{\section}
     {\normalfont\fontsize{13}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
     {\normalfont\fontsize{12}{15}\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
     {\normalfont\fontsize{11}{15}\bfseries}{\thesubsubsection}{1em}{}
%     \def\thesection{\arabic{section}}
%\def\thesubsection{\arabic{section}.\arabic{subsection}}
\def\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

\tableofcontents
%\tableofcontents{}
%\setcounter{page}{1}
%\,\,\,\renewcommand{\contentsname}{\textbf{TABLE OF CONTENTS\normalsize\centering}}
\pagenumbering{roman} % Roman page number for toc
\setcounter{page}{10} % Make it start with "ii"
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\listtablename}{LIST OF TABLES}
%\tableofcontents{} % Print table of contents

 \titleformat{\chapter}[display]{\large\bfseries\raggedright}%
     {\chaptername~\thechapter}{1ex}{}[{\titlerule[1pt]}]
\newpage
\listoffigures
\newpage
\listoftables{}
\newpage
%\addcontentsline{toc}{chapter}{List of Abbreviations}
%\input{./abbrev_body}

\pagenumbering{arabic} % Start text with arabic 1
\titleformat{\chapter}[display]{\vspace{7.5cm}\Large\bfseries\centering}%
    {\chaptername~\thechapter}{1ex}{}

%\input{./chaps/abstract}

%\input{./chaps/Chap1_V1}
%\input{./chaps/Chap2_V1}
%%\input{./chaps/chap1a}
%\input{./chaps/Chap3_V1}
%\input{./chaps/Chap4_V1}
%\input{./chaps/Chap5_V1}
%\input{./chaps/Chap6_V1}
%%\input{./chaps/chap65}
%\input{./chaps/Refrences_V1}
\end{document}

答案1

文档类report不会生成您的错误。这是由于错误的标题选项设置造成的。

该包caption定义了一系列字体选项,包括字体大小、形状(、、、ip)、系列、家族等。所有这些选项不应单独用于标题选项,而应始终与选项结合使用。例如:itslscfont

\usepackage[font=small, labelfont=bf,textfont=it,format=plain,]{caption}

或者与其他一些选项结合使用,例如:

\usepackage[font={small,stretch=0.84}, labelfont=bf,textfont=it,format=plain,]{caption}

但永远不会(正如你在标题定义中所写:

\usepackage[font=small,format=plain,labelfont=bf,up,textfont=it,up]{caption}

笔记:当你使用矛盾的选项时,相似的选项textfont{it,up}将优先于最后的选项,即up

我怀疑,在您的情况下,上面标题设置中的第一个示例就是您想要的。有了它,您将获得以下结果:

在此处输入图片描述

具有正确代码的完整 MWE 是:

\documentclass[12pt, a4paper]{report} % Report class in 11 points
\usepackage[hmargin=1.5in, vmargin=1.7in]{geometry}
\usepackage[titles]{tocloft}
\usepackage{afterpage}
%\usepackage{sectsty}
\usepackage[demo]{graphicx}% in real document remove option "demo
%\usepackage{graphics}
\usepackage{multirow}
\usepackage{array}
%\usepackage{caption} 
\usepackage{subcaption}
\usepackage{cases}
\usepackage[font=small,format=plain,labelfont=bf,textfont=it]{caption}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\usepackage{titlesec}
\titleformat{\chapter}[display]{\large\bfseries\centering}%
    {\chaptername~\thechapter}{1ex}{}
\usepackage{lipsum}

%\allsectionsfont{\usefont{OT1}{times}{bc}{n}\bf\selectfont}
%\onehalfspace
\titlepage
\begin{document}

\begin{figure}[!htp]
 \begin{subfigure}[b]{1\textwidth}
 \centering
       \includegraphics[scale=0.6]{DAPS.eps}
        \caption{DAPS}
        \label{fig:(DAPS)}
    \end{subfigure}

 \begin{subfigure}[b]{1\textwidth}
 \centering
        \includegraphics[scale=0.6]{RTPS.eps}
        \caption{RTPS }
      \label{fig:(RTPS)}
    \end{subfigure}

  \begin{subfigure}[b]{1\textwidth}
  \centering
        \includegraphics[scale=0.6]{ToUS.eps}
        \caption{ToUSP}
\label{fig:(c)}
    \end{subfigure}
\caption{Price}
\label{PDR}
\end{figure}
\end{document}

相关内容