titlesec - 设置附录和参考书目的顶部边距

titlesec - 设置附录和参考书目的顶部边距

不久前,有人帮助我使用 titlesec 格式化论文的章节标题。今天,一位审阅者说附录和参考书目需要 1 英寸的上边距。我该怎么做?谢谢。

\documentclass[letter, 12pt]{report}
\usepackage{cite}
\usepackage{amsthm}
\usepackage{amsmath}
\newtheorem{definition}{Definition}
\usepackage[tight,footnotesize]{subfigure}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage[breaklinks = true]{hyperref} 
\usepackage{color}
\usepackage{caption}
\usepackage{url}
%\usepackage{lscape}
%\usepackage{times}
%\usepackage{minted}
%\usepackage{listings}

\usepackage{textcomp}
\definecolor{listinggray}{gray}{0.9}
\definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
\usepackage{setspace}
\doublespacing
\usepackage{indentfirst}
\usepackage[top=1.0in, bottom=1.25in, left=1.5in, right=1.0in]{geometry}

\usepackage{etoolbox}

\patchcmd{\thebibliography}{\chapter*{\bibname}}{\chapter*{\MakeUppercase{\bibname}}}{}{}

\usepackage{titlesec}
 \titlespacing*{\chapter}{0pt}{1in}{20pt}
 \titleformat{\chapter}[display]
   {\centering\normalfont\normalsize}{\MakeUppercase{\chaptertitlename} \thechapter}{0pt}{\small}

 \titleformat{\section}
     {\normalfont\normalsize\bfseries}{\thesection}{1em}{}
 \titleformat{\subsection}
     {\normalfont\normalsize\bfseries}{\thesubsection}{1em}{}
 \titleformat{\subsubsection}
     {\normalfont\normalsize\bfseries}{\thesubsubsection}{1em}{}

\begin{document}
\raggedright
\setlength{\parindent}{1cm}
\chapter{INTRODUCTION}
\chapter{PROBLEM}
\appendix

\chapter{CODES}
\chapter{LIST OF PUBLICATIONS}

\begin{thebibliography}{100}
\bibitem{Niesen}
Niesen.
\newblock Social networks/blogs now account for one in every four and a half minutes online.
\newblock {\em http://blog.nielsen.com/nielsenwire/global/social-media-accounts-for-22-percent-of-time-online/}.
\newblock (June 2010).
\end{thebibliography}
\end{document}

答案1

在您的示例中,附录章节和未编号参考书目之前的空格与主要章节的空格相同(大概是 1 英寸,如您在 中指定的\titlespacing*)。如果您需要从附录章节开始使用不同的空格(尽管这似乎不一致),请在文档正文中\titlespacing*立即发出另一个空格。\appendix

请注意,在的“代码之前”参数中\titleformat“最后一个命令可以接受一个参数,即标题文本”(手册,第 4 页)。也就是说,您可以使用\MakeUppercase和 ,而无需将章节名称大写。还请注意(在titlesec命令中)您应该用 替换\centering\filcenter以确保正确的左右间距。

\documentclass[12pt]{report}

\usepackage[doublespacing]{setspace}

\usepackage{titlesec}
\titlespacing*{\chapter}{0pt}{1in}{20pt}
\titleformat{\chapter}[display]
    {\filcenter\normalfont\normalsize}{\MakeUppercase{\chaptertitlename} \thechapter}{0pt}
    {\small\MakeUppercase}

\begin{document}

\chapter{Introduction}

\appendix
\titlespacing*{\chapter}{0pt}{0.5in}{20pt}

\chapter{Codes}

\begin{thebibliography}{100}
\bibitem{Niesen}
Niesen.
\newblock Social networks/blogs now account for one in every four and a half minutes online.
\newblock {\em http://blog.nielsen.com/nielsenwire/global/social-media-accounts-for-22-percent-of-time-online/}.
\newblock (June 2010).
\end{thebibliography}

\end{document}

相关内容