
我正在努力開發反映公司目前要求的自訂報告類別。目標是鼓勵人們使用 LaTeX 作為報告技術內容的主要工具。我想盡可能降低進入門檻。這就是為什麼處理所有格式的類別似乎是一個好主意。我即將完成,但需要您的支援來解決與每個附錄的自訂封面頁相關的問題。使用當前程式碼我實現了這一點:
我知道這看起來很像主文檔的封面,但是......無論如何。
我的課:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myreport}[2018/08/29 My report LaTeX class]
\DeclareOption{twocolumn}{\OptionNotUsed}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions\relax
\LoadClass[onecolumn, 10pt]{report}
\RequirePackage[a4paper, left=2.5cm,right=2.5cm,top=2cm,bottom=3.5cm]{geometry}
\RequirePackage[toc, title]{appendix}
\RequirePackage{xpatch}
\RequirePackage{etoc}
\RequirePackage{lastpage}
\RequirePackage{fancyhdr}
\RequirePackage{xcolor}
%*********************************************************
% CUSTOM COLORS
%*********************************************************
\definecolor{MyBlue}{RGB}{0,65,101}
%*********************************************************
% SECTION REDEFINITION
%*********************************************************
\renewcommand\chapter{\@startsection {chapter}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries\color{MyBlue}}}
\renewcommand\section{\@startsection {section}{2}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\large\bfseries\color{MyBlue}}}
\renewcommand\subsection{\@startsection{subsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries\color{MyBlue}}}
\renewcommand\subsubsection{\@startsection{subsubsection}{4}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries\color{MyBlue}}}
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
%*********************************************************
% COUNTERS FOR FIGURES AND TABLES INCLUDE SECTION NUMBER
%*********************************************************
\setcounter{secnumdepth}{4} %depth for numbering
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
%*********************************************************
% CUSTOM APPENDIX
%*********************************************************
\renewcommand\appendixname{Appendix}
\renewcommand\appendixtocname{Appendices}
\renewcommand\appendixpagename{Appendix}
%redefinition of appendices environment from 'appendix' package
%this set up ToC depth
\let\oldappendices\appendices
\def\appendices{\oldappendices\etocdepthtag.toc{mtappendix}\etocsettagdepth{mtchapter}{none}\etocsettagdepth{mtappendix}{subsection}}
%*********************************************************
% TITLE PAGE
%*********************************************************
\renewcommand*{\maketitle}{%
\thispagestyle{empty}
\begin{center}
\bfseries
\huge Main Title Of The Document
\vskip.5in
\LARGE Task title
\vskip.2in
\vskip.2in
\LARGE Rev no
\vspace{10cm}
\end{center}
\newpage
}
%*********************************************************
% HEADER AND FOOTER STYLE
%*********************************************************
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\headrulewidth}{0pt} % no line in header area
\fancyfoot{} % clear all footer fields
\renewcommand{\footrule}{{\color{MyBlue}\vskip-\footruleskip\vskip-\footrulewidth \hrule width\headwidth height \footrulewidth\vskip\footruleskip}}
\renewcommand{\footrulewidth}{3pt}
\renewcommand\thefootnote{\textcolor{red}{\arabic{footnote}}}
\fancyfoot[RE,LO]{\footnotesize \textcolor{MyBlue} {\vskip.3cm TaskNo XXX \ - Rev.XXX}} % other info in "inner" position of footer line
\fancyfoot[LE,RO]{\footnotesize \textcolor{MyBlue} {\vskip.3cm Page \thepage\ of \pageref{LastPage}}} % page number in "outer" position of footer line
以及使用上面的類別的範例報告:
\documentclass[a4paper, 10pt]{myreport}
\begin{document}
\maketitle %creates custom cover page
\tableofcontents %creates main table of content
\newpage %start first chapter from new page
%************************** INPUT DOCUMENT CONTENT **************************************
%******************************************************************************************
\chapter{Introduction}
Some text in main document.
%************************** APPENDICIES *************************************************
%******************************************************************************************
\begin{appendices}
\chapter{Additional information}
\localtableofcontents
\section{Section 1}
Some text
\section{Section 2}
Some text
\end{appendices}
\end{document}
這是簡化版本,但我相信它足以展示案例。
顯然,在尋求你的幫助之前我嘗試自己做,但我在這裡所以結果是已知的:)
這似乎是類似的主題,但我無法讓它為我工作。我將不勝感激您的評論。謝謝!