如何使标题居中?
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage[colorlinks,citecolor=blue,urlcolor=blue,linkcolor=black]{hyperref}
\usepackage{hypernat}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[margin=2.5cm]{geometry}
\usepackage{url}
\usepackage{booktabs,caption,fixltx2e}
\usepackage[flushleft]{threeparttable}
\usepackage{setspace}
\usepackage[capposition=top]{floatrow}
\usepackage{float}
\usepackage{rotating}
\usepackage{bm}
\usepackage{tabularx}
\onehalfspacing
\usepackage{graphicx}
\usepackage{subfig}
\renewcommand{\familydefault}{\sfdefault}
\font\titlefont=cmr12 at 40pt
\begin{document}
\pagenumbering{gobble}% Remove page numbers (and reset to 1)
\begin{center}
\color{white}{
\titlefont
{\fontfamily{cmss}\selectfont
\scalebox{5}{Big Title}
}
\titlefont \\
\vspace{2cm}
{\fontfamily{cmss}\selectfont
\scalebox{2}{Small title}
}
}
\end{center}
\pagecolor{purple}\afterpage{\nopagecolor}
\newpage
\tableofcontents
\end{document}
答案1
要使标题垂直居中,请将说明放在\vspace*{\fill}
前面\begin{center}
,将说明\vspace*{\fill}
放在后面\end{center}
。
我认为你应该简化和整理你使用的 LaTeX 代码,因为它目前相当不透明、不必要地复杂,而且充满了冗余。不要多次加载包,并确保加载hyperref
最后的。哦,您可能已经发现,您不能同时加载subcaption
和subfig
。
我尝试在以下版本的代码中做了初步清理。请尝试仔细阅读前言并删除文档中所有您根本不使用的包。
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\onehalfspacing
\usepackage{caption}
\usepackage{subcaption}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{xcolor}
\usepackage{verbatim}
\usepackage[margin=2.5cm]{geometry}
\usepackage[hyphens,spaces]{url} % 'hyphens' and 'spaces' options are very useful
\usepackage{booktabs}
%%,caption} % no need to load twice
%% ,fixltx2e} % no need to load unless your TeX distribution is *ancient*
\usepackage[flushleft]{threeparttable}
%%\usepackage{setspace} % no need to load twice
\usepackage[capposition=top]{floatrow}
\usepackage{float}
\usepackage{rotating}
\usepackage{bm}
\usepackage{tabularx}
%%\usepackage{graphicx} % is loaded automatically by 'rotating' package
%% Load 'hyperref' package *last*
\usepackage[colorlinks,citecolor=blue,urlcolor=blue,
linkcolor=black]{hyperref}
%% \usepackage{hypernat} % no need to load unless your TeX distribution is **ancient**
%%\usepackage{subfig} % conflicts with 'subcaption'
\renewcommand{\familydefault}{\sfdefault}
% ------- end of preamble -------- %
\begin{document}
\pagenumbering{gobble}
\pagecolor{purple}
\vspace*{\fill}
\begin{center}
\color{white}
\scalebox{5}{Big Title}\\[2cm]
\scalebox{2}{Small title}
\end{center}
\vspace{\fill}
\newpage
\nopagecolor
\tableofcontents
% remainder of document
\end{document}