如何在 Latex 项目的 .cls (类) 中定义子图?

如何在 Latex 项目的 .cls (类) 中定义子图?

对于我的论文工作,我有一个大学提供的模板,其中包含一个类(.cls)、多个部分(.tex)和一个参考书目(.bib),这些文件位于单独的文件中。在 thesisclass.cls 文件中,所有内容都已定义,并在 main.tex 文件中作为\documentclass{thesisclass}.

现在的问题是,thesisclass.cls 中没有提供子标题。因此我无法像在许多教程中看到的那样制作子图和标题。有人能帮我在 thesisclass.cls 文件中定义子图和标题吗?

如果有人想看我的整个论文文件(不包括内容),我可以提供。

现在您可以看到我的 thesisclass.cls 如下:

\NeedsTeXFormat{LaTeX2e}                                        % We do need LaTeX2e
\ProvidesClass{thesisclass}
\LoadClass[a4paper,12pt,titlepage]{scrbook} % Class based on scrbook

%% Packages
%%---------
\renewcommand{\familydefault}{\sfdefault}
\usepackage{helvet}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage{vmargin}
\usepackage{fancyhdr}
\usepackage{pdfpages}
\usepackage{subfigure}
\usepackage{ae}
\usepackage{url}
\usepackage[absolute, overlay]{textpos}
\usepackage{tikz}
\usepackage[ngerman, english]{babel}%, english
\usepackage[style=authoryear, backend=biber, maxcitenames=2, uniquelist=true, giveninits=true]{biblatex}
\usepackage{csquotes}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage[raiselinks = true, bookmarks = true, bookmarksopenlevel = 1, bookmarksopen=true, hyperindex = true, plainpages  = false, pdfpagelabels = true, pdfborder = {0.5}, colorlinks = true,  linkcolor = black, citecolor = black, filecolor = black, urlcolor = black]{hyperref}
\usepackage[absolute]{textpos}
\usepackage{nomencl}
\usepackage{setspace}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{subcaption}

%% New commands
%%-------------

\newcommand{\changefont}[3]{\fontfamily{#1} \fontseries{#2} \fontshape{#3} \selectfont}
\newcommand{\chapterheadfont}{}
\newcommand{\blankpage}{}
\clearpage{\pagestyle{empty}\cleardoublepage}

%% Globalsetting
%%--------------
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\setpapersize{A4}
\setmarginsrb{3cm}{1cm}{3cm}{1cm}{6mm}{7mm}{5mm}{15mm}

\parindent 0cm
\parskip1.5ex plus 0.5ex minus 0.5ex
\changefont{phv}{m}{n}

\onehalfspacing

%% Headings
%%---------
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyhf{}
\fancyhead[LO]{\headfont\nouppercase{\rightmark}}   % Header for left page (odd)
\fancyhead[RE]{\headfont\nouppercase{\leftmark}}    % Header for right page (even)
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{%
\fancyhf{}                                          % No Header and Footer fields
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[C]{\thepage}
}

%% Style of Captions
%%------------------
\renewcommand{\chaptername}{}
{\chapterheadstartvskip}
\renewcommand{\section}{%
\@startsection{section}%
{1}     % Structure level
{0mm}   % Indention
{2ex plus 1ex minus 1ex}            % Pre-Margin
{0.5ex plus 0.5ex minus 0.5ex}      % Post-Margin
{\chapterheadfont\Large\bfseries}   % Style
%
}
\renewcommand{\subsection}{%
\@startsection{subsection}%
{2}     % Structure level
{0mm}   % Indention
{1.5ex plus 1ex minus 0.5ex}        % Pre-Margin
{0.3ex plus 0.3ex minus 0.3ex}      % Post-Margin
{\chapterheadfont\large\bfseries}   % Style
}
\renewcommand{\subsubsection}{%
\@startsection{subsubsection}%
{3}     % Structure level
{0mm}   % Indention
{1.5ex plus 1ex minus 0.5ex}            % Pre-Margin
{0.2ex plus 0.2ex minus 0.2ex}          % Post-Margin
{\chapterheadfont\normalsize\bfseries}  % Style
}
\renewcommand{\paragraph}{%
\@startsection{paragraph}%
{4}     % Structure level
{0mm}   % Indention
{1.3ex plus 1ex minus 0.3ex}            % Pre-Margin
{0.2ex plus 0.2ex minus 0.2ex}          % Post-Margin
{\chapterheadfont\normalsize\bfseries}  % Style
}
\renewcommand{\subparagraph}{%
\@startsection{subparagraph}%
{5}     % Structure level
{0mm}   % Indention
{1ex plus 1ex minus 0.2ex}              % Pre-Margin
{0.1ex plus 0.1ex minus 0.1ex}          % Post-Margin
{\chapterheadfont\normalsize\bfseries}  % Style
}




%%  Style of chapter captions  
%% ---------------------------------
\newlength{\chapnolen}
\newlength{\chapparlen}
\newsavebox{\chapno}
\renewcommand{\@makechapterhead}[1]{
  \vspace*{0.2\textheight}
  \vskip -70\p@
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \savebox{\chapno}{\chapterheadfont\huge\bfseries \thechapter.}
        \settowidth{\chapnolen}{\usebox{\chapno}}
        \parbox[t]{\chapnolen}{\usebox{\chapno}}\nobreak\leavevmode
      \fi
    \fi
    \interlinepenalty\@MM
    \setlength{\chapparlen}{\textwidth}
    \addtolength{\chapparlen}{-1.0\chapnolen}
    \addtolength{\chapparlen}{-2ex}
    \leavevmode\nobreak
    \parbox[t]{\chapparlen}{\raggedright\chapterheadfont\huge \bfseries #1\par\nobreak}
    \vskip 40\p@
  }}

\renewcommand{\@makeschapterhead}[1]{
  \vspace*{50\p@}
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \chapterheadfont \huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }
}

%% Style of content directory   
%% ---------------------------------
\let\oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{{\pdfbookmark{\contentsname}{\contentsname}\chapterheadfont\oldtableofcontents}}
\let\@olddottedtocline\@dottedtocline
\renewcommand{\@dottedtocline}[5]{\@olddottedtocline{#1}{#2}{#3}{#4}{\chapterheadfont #5}}


%%  Style of appendix numbering  
%% ----------------------------------
 \renewcommand\appendix{\par 
   \setcounter{section}{0}% 
   \setcounter{subsection}{0}% 
   \setcounter{figure}{0}%
   \renewcommand\thesection{\Alph{section}}% 
   \renewcommand\thefigure{\Alph{section}.\arabic{figure}} 
   \renewcommand\thetable{\Alph{section}.\arabic{table}}}


%%  Abstract 
%% -----------------------------

\newcommand{\abstract}[1][\abstractname]{\chapter*{#1}}
\newcommand{\Abstract}[1][\abstractname]{\chapter*{#1}} 

\def\ackname{Acknowledgments}
\def\abstractname{Abstract}
\def\switcht@deutsch{\svlanginfo}
\def\switcht@english{\svlanginfo
    \def\abstractname{Abstract}
} 

bibliogray 也有定义,但与此无关。

答案1

我解决了这个问题。删除subfigure是解决方案。感谢您在评论中支持。

相关内容