我有一份带有标题页的标准报告,但出于某种奇怪的原因,我每次都会在第一页看到空白页。我跟踪了代码,但似乎没有任何\clearpage
命令。有人能告诉我这是什么原因造成的吗?
最小工作示例(test.tex):
\documentclass[paper=a4, fontsize=11pt]{report}
\usepackage[T1]{fontenc} % 8 bit encoding allows for more string types
\usepackage{array} % For cell centering in tables
\usepackage{fourier} % Superior font package
\usepackage{ulem} % for strikethroughs
\usepackage[english]{babel} % English language/hyphenation (allows for smarter hyphenation)
\usepackage[protrusion=true,expansion=true]{microtype} % Better typography
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{graphicx} % for importing images. By default will load with pdflatex argument. Use PDF images whenver possible because, provided they are vector, they scale better.
\usepackage{caption} % Caption images
\usepackage{subcaption} % Sub-caption Images
\usepackage{color,soul} % For text coloring and highlighting
\usepackage{url} % For creating URLs
\usepackage{xstring} % if conditionals in new commands
\usepackage{listings} % Embed code
\usepackage{hyperref} % For displaying different document links
%\usepackage{dirtree} % Folder tree structure
%\usepackage[acronym]{glossaries} % Glossaries instead of newcommand. make sure to use [acronym] insteaad of [toc]
\usepackage[acronym]{glossaries-extra} % Glossaries instead of newcommand. make sure to use [acronym] insteaad of [toc]. Glossaries-extra to make use of supressing linking of glossaries but not acronyms
\usepackage{sectsty} % Custom sectioning (sectsty package)
\usepackage{fancyhdr} % Custom headers/footers (fancyhdr package)
\usepackage{placeins} % Place Tables at exact location
\usepackage{lipsum} % For lorum ipsum
\usepackage{enumitem} % Reduce spacing in lists
\usepackage[table]{xcolor} % Tooltip boxes
\usepackage{longtable}
\usepackage[tikz]{bclogo}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[many]{tcolorbox}
\usepackage{multirow} % Multi row data in tables
\usepackage[latin1]{inputenc} % used for tikz below
\usepackage{tikz} % Used for flowcharts
\usepackage{float}
\usepackage{indentfirst}
\usepackage{fontawesome} %Using the \faIls symbol for virtual commodity
\usepackage{tabularx}
\usepackage{setspace} %for double spacing
\doublespacing
%\renewcommand*{\acronymtype}{acronym}
\numberwithin{equation}{section} % Equationnumbering: section.eq#
\numberwithin{figure}{section} % Figurenumbering: section.fig#
\numberwithin{table}{section} % Tablenumbering: section.tab#
\setlength{\parskip}{1em} % larger space between paragraphs
\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Maketitle metadata
\setlist{nolistsep}
\definecolor{bgblue}{RGB}{245,243,253}
\definecolor{ttblue}{RGB}{91,194,224}
\definecolor{blue}{rgb}{0,0,0.82} % for listings
\definecolor{dkgreen}{rgb}{0,0.6,0} % for listings
\definecolor{gray}{rgb}{0.5,0.5,0.5} % for listings
\definecolor{mauve}{rgb}{0.58,0,0.82} % for listings
\setcounter{secnumdepth}{5} % depth at which to stop numbering sections
\setcounter{tocdepth}{5} % depth at which to stop table of contents
\allsectionsfont{\normalfont\scshape} % Change font of al section commands
\hypersetup{
colorlinks,
citecolor=blue,
filecolor=black,
linkcolor=blue,
urlcolor=blue,
breaklinks=true
}
%linkcolor is for glossaries
\makeglossaries
\pagestyle{fancyplain}
% Right footer (used as page number)
\renewcommand{\headrulewidth}{0pt} % Remove header underlines
\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
\setlength{\headheight}{13.6pt}
%\usetikzlibrary{shapes,arrows,trees}
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
decorations.pathreplacing,decorations.pathmorphing,shapes,%
matrix,shapes.symbols}
\mdfdefinestyle{mystyle}{ %
rightline=true,
innerleftmargin=10,
innerrightmargin=10,
outerlinewidth=3pt,
topline=false,
rightline=true,
bottomline=false,
skipabove=\topsep,
skipbelow=\topsep
}
\newtcolorbox{myboxi}[1][]{
breakable,
title=#1,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
bottomrule=0pt,
toprule=0pt,
leftrule=3pt,
rightrule=3pt,
titlerule=0pt,
arc=0pt,
outer arc=0pt,
colframe=black,
}
\newtcolorbox{myboxii}[1][]{
breakable,
freelance,
title=#1,
colback=white,
colbacktitle=white,
coltitle=black,
fonttitle=\bfseries,
bottomrule=0pt,
boxrule=0pt,
colframe=white,
overlay unbroken and first={
\draw[red!75!black,line width=3pt]
([xshift=5pt]frame.north west) --
(frame.north west) --
(frame.south west);
\draw[red!75!black,line width=3pt]
([xshift=-5pt]frame.north east) --
(frame.north east) --
(frame.south east);
},
overlay unbroken app={
\draw[red!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[red!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
overlay middle and last={
\draw[red!75!black,line width=3pt]
(frame.north west) --
(frame.south west);
\draw[red!75!black,line width=3pt]
(frame.north east) --
(frame.south east);
},
overlay last app={
\draw[red!75!black,line width=3pt,line cap=rect]
(frame.south west) --
([xshift=5pt]frame.south west);
\draw[red!75!black,line width=3pt,line cap=rect]
(frame.south east) --
([xshift=-5pt]frame.south east);
},
}
\lstset{frame=tb,
language=php,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
otherkeywords={var,class, @param, @pre, @post, @return, public, protected, private, bool},
commentstyle=\color{dkgreen},
morecomment=[l][\color{magenta}]{\#},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
moredelim=**[is][\color{blue}]{@}{@},
moredelim=**[is][\color{gray}]{`}{`},
tabsize=3
}
\lstnewenvironment{code}[1][]%Don't break listings at end of page
{\noindent\minipage{\linewidth}\medskip}
{\endminipage}
\newcommand{\renewglossaryentry}[1]{%
\ifglsentryexists{#1}
{\global\csundef{glo@#1@name}}
{
\newglossaryentry{#1}
}
}
\setabbreviationstyle[acronym]{long-short}
% Glossaries
\glssetcategoryattribute{glossary}{nohyper}{false}
\glssetcategoryattribute{acronym}{nohyper}{false}
\newglossaryentry{sample-glossary-entry}
{
name={Sample Glossary Entry},
text={sample glossary entry},
first={\textbf{Sample Glossary Entry}},
plural={sample glossary entries},
firstplural={\textbf{Sample Glossary Entries}},
description={Sample glossary entry for the general glossary},
category={glossary}
}
\fancyhead[L]{}
\fancyhead[C]{Internal Use Only}
\fancyhead[R]{} % Page Header
\fancyfoot[L]{} % Left footer
\fancyfoot[C]{CONFIDENTIAL} % Center footer
\fancyfoot[R]{\thepage}
\title{
%\vspace{-1in}
\usefont{OT1}{bch}{b}{n}
\normalfont \normalsize \textsc{Title} \\ [25pt]
\horrule{0.5pt} \\[0.4cm]
\Huge Description\\
\huge Details\\
\LARGE {\color{red} More Details}\\
\LARGE \today\\
\horrule{2pt} \\[0.5cm]
}
\author{
\normalfont \normalsize
John Smith\\[-3pt] \normalsize
James Bond\\[-3pt] \normalsize
Jean Luc Picard\\[-3pt] \normalsize
\vspace*{20mm}
\date{\today}
}
%%% Begin document
\begin{document}
\pagenumbering{gobble}
\maketitle
\clearpage
\printglossary
\clearpage
\tableofcontents
\clearpage
\pagenumbering{arabic}
\chapter{Some Chpater}
bla bla bla
\section{Some Section}
This is the \gls{sample-glossary-entry}.
\end{document}
我是这样编译的:
pdflatex test
pdflatex test
makeglossaries test
pdflatex test
答案1
选项1(这个结果更清晰)
根据此解决方案来自 Werner,在序言中添加以下代码可以消除空白的第一页:
\usepackage{atbegshi}% http://ctan.org/pkg/atbegshi
\AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}
选项 #2
或者,删除\vspace*{20mm}
作者信息可以消除空白的第一页,但您需要找到另一种方法来纠正间距。
答案2
您还可以利用titlepage
如以下示例所示的环境:
\documentclass[paper=a4, fontsize=11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{setspace}
\doublespacing
\usepackage{showframe}
\newcommand{\horrule}[1]{\rule{\linewidth}{#1}}
\begin{document}
\begin{titlepage}
\centering
\usefont{OT1}{bch}{b}{n}
\normalfont \normalsize \textsc{Title} \\ [25pt]
\horrule{0.5pt} \\[0.4cm]
\Huge Description
\huge Details
\LARGE { More Details}
\LARGE \today\\
\horrule{2pt} \\[0.5cm]
\normalfont\normalsize
John Smith\\[-3pt]
James Bond\\[-3pt]
Jean Luc Picard\\[-3pt]
\vspace*{20mm}
\today
\end{titlepage}
\end{document}