![关于文本居中和添加目录边框的问题](https://linux22.com/image/421683/%E5%85%B3%E4%BA%8E%E6%96%87%E6%9C%AC%E5%B1%85%E4%B8%AD%E5%92%8C%E6%B7%BB%E5%8A%A0%E7%9B%AE%E5%BD%95%E8%BE%B9%E6%A1%86%E7%9A%84%E9%97%AE%E9%A2%98.png)
我想在我的文档中做两件事
- 为我的目录添加边框
- 将表格标题与页面标题居中/对齐
在下图中,我仅显示内容(不是整个页面,其余部分为空白)。这是我希望页面显示的样子:
我的代码如下,首先我有一个名为的类文件,Vakalatnama.cls
其中包含大部分代码:
\ProvidesClass{vakalatnama}[2020/09/15 Vakalatnama template for Indian courts]
\LoadClass{article}
\RequirePackage{xparse}
\RequirePackage[driver=xetex,a4paper,noheadfoot,includeheadfoot,nomarginpar,top=1.5in,bottom=1.5in,left=1.75in,right=1.0in]{geometry}
\RequirePackage{xunicode}
% \RequirePackage{xltxtra}
% Make entries in the index table as links
\RequirePackage[linktocpage=true]{hyperref}
% Set font to Times New Roman
\RequirePackage{fontspec}
\setmainfont{Times New Roman}
% line spacing = 1.5
\RequirePackage[onehalfspacing]{setspace}
\RequirePackage[parfill]{parskip}
% Format section title to have numbers in Table of Contents, but not in document
\newcommand\secpagebreak{}
\RequirePackage{titlesec}
\titleformat{\section}{\center \normalfont \bfseries}{}{0pt}{\secpagebreak}
\setcounter{section}{1}
\RequirePackage{fontenc}
\hyphenation{con-sti-tu-tion-al}
% Set title of Table of Contents from Contents -> Particulars. '*' implies that
% the argument must not be in multiple paragraphs i.e. /long
\renewcommand*{\contentsname}{
\par\noindent\hspace*{\fill} \textbf{\underline{Index}} \hspace*{\fill} \\*
\hspace*{-10pt}\underline{{\textbf{Si. No.}}} \hfill \underline{\textbf{Particulars}} \hfill \underline{\textbf{Page}}
}
\newcommand{\pnp}{Test Solicitor}
\newcommand{\dhc}{Delhi High Court}
\newcommand{\sci}{Supreme Court of India}
\newcommand{\petitioner}[1]{\newcommand{\@petitioner}{#1}}
\newcommand{\respondent}[1]{\newcommand{\respndt}{#1}}
\newcommand{\court}[1]{\newcommand{\crt}{#1}}
\newcommand{\jurisdiction}[1]{\newcommand{\jurisdctn}{#1}}
\newcommand{\petitiontype}[1]{\newcommand{\ptntype}{#1}}
\NewDocumentCommand {\setname} {O{Shri} m m} { % Title (default=Shri), first, last
\newcommand {\tfname} {#1 #2 #3} % Full name with title
\newcommand {\fname} {#2 #3} % first + last name
\newcommand {\tlname} {#1 #3} % title + last name
}
\newcommand{\advocate}[2][Shri]{
\newcommand{\adv}{#2}
\newcommand{\fulladv}{#1 #2}
}
\newcommand{\clientdetails}[1]{\newcommand{\clntdtls}{#1}}
\newcommand{\caseNumbers}[2]{
\newcommand{\fullcasenumber}{#1 of #2}
\newcommand{\shortcasenumber}{#1/#2}
}
\newcommand{\casetitle}{
\begin{center}
\textsc{In the \crt{}} \newline
\textsc{\jurisdctn{}} \newline
\textsc{\ptntype{} \fullcasenumber{}} \newline
\end{center}
}
\newcommand{\inmatterof}{%
\begin{tabular}{l c r}
\multicolumn{3}{l}{\underline{\textsc{In the matter of:}}} \tabularnewline
\tabularnewline
\@petitioner & \ldots & Petitioner \\* %\tabularnewline
\multicolumn{3}{c}{-- \textsc{versus} --} \tabularnewline
\respndt & \ldots & Respondent \tabularnewline
\end{tabular}
}
\newcommand{\parties}{%
\begin {center}
\begin{tabular}{l c r}
\@petitioner & \ldots & Appellant/Petitioner \tabularnewline
\multicolumn{3}{c}{-- \textsc{Between/And} --} \tabularnewline
\respndt & \ldots & Defendant/Respondent/Opposite Party \tabularnewline
\end{tabular}
\end{center}
}
\newcommand{\tophead}{%Roll the Court Name, petition etc into a single command
\casetitle{}
\inmatterof{}
}
\renewcommand \maketitle {
% Cover page
\thispagestyle{empty}
\pagenumbering{gobble}
\casetitle{}
\inmatterof{}
\vspace*{5em}
\tableofcontents
\vspace*{5em}
\textbf{Advocate for the Respondent: \respndt{}}
\renewcommand\secpagebreak{\clearpage}
}
\ProcessOptions\relax
\endinput
进而main.tex
\begin{document}
\petitioner{Test Petitioner}
\court{Supreme Court Of India}
\respondent{State of Uttar Pradesh and Others}
\jurisdiction{Criminal Appellate Jurisdiction}
\petitiontype{SLP (Civil)}
\caseNumbers{1152}{2000}
\advocate{\pnp}
\clientdetails{Test Petitioner}
\maketitle
\setcounter{page}{1}
\pagenumbering{arabic}
\section{Vakalatnama}
\section{Memo of Appearance}
\end{document}
预先感谢您的帮助 :-)
答案1
我etoc
在我的类文件中使用了如下包:
% Format Table of Contents
\RequirePackage{etoc}
\newcommand{\titleoftoc}{\textsc{Index}}
\newcommand{\mktoc}{% Cover page
\begin{center}
\etocsetstyle{section}
{}
{\etociffirst{ \\ \hline}{\\\hline}}
{\etocnumber & \etocname & \etocnumber }
{}
\etocsettocstyle{\hypersetup{hidelinks}
\begin{tabular}{|c|l|c|}
\multicolumn{3}{c}{\titleoftoc} \\
\hline
\multicolumn{1}{|c|}{\bfseries Si No} &
{\bfseries Particulars} &
{\bfseries Page}
}
{\\ \hline\end{tabular}}
\etocglobaldefs
\etocsetnexttocdepth{1}
\tableofcontents
\end{center}
}
之后,在main.tex
\begin{document}
% Set other paramaters
\mktitle
\section{AAA}
\section{BBB}
\end{document}