我正在使用R
该knitr
软件包生成LaTeX
PDF。如下面的 MWE 所示,在我的方框页面(将用作书的封面)之前创建了一个额外的空白页。
如果我删除 Release 1.0 行后面的 final \\
,多余的页面就会消失。但这似乎是一个不靠谱的解决方案。更重要的是,同样的更改并没有解决我较长的文档中的问题。
我将非常感激能够发现我做错了什么。
编辑:根据 DAVID Carlisle 的建议,我希望这是原文:
\documentclass{book}
\usepackage{graphicx}
\usepackage{color}
%% maxwidth is the original width if it is less than linewidth
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
\makeatletter
\def\maxwidth{ %
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
\let\hlipl\hlkwb
\usepackage{framed}
\makeatletter
\newenvironment{kframe}{%
\def\at@end@of@kframe{}%
\ifinner\ifhmode%
\def\at@end@of@kframe{\end{minipage}}%
\begin{minipage}{\columnwidth}%
\fi\fi%
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
\colorbox{shadecolor}{##1}\hskip-\fboxsep
% There is no \\@totalrightmargin, so:
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\MakeFramed {\advance\hsize-\width
\@totalleftmargin\z@ \linewidth\hsize
\@setminipage}}%
{\par\unskip\endMakeFramed%
\at@end@of@kframe}
\makeatother
\definecolor{shadecolor}{rgb}{.97, .97, .97}
\definecolor{messagecolor}{rgb}{0, 0, 0}
\definecolor{warningcolor}{rgb}{1, 0, 1}
\definecolor{errorcolor}{rgb}{1, 0, 0}
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX
\usepackage{alltt}
\usepackage[margin = 0.8in]{geometry}
\usepackage{afterpage} % if coloring only one page, like the cover, use this at end
% https://tex.stackexchange.com/questions/25137/how-to-change-the-background-color-only-for-the-current-page
\usepackage{pagecolor}
\usepackage{xcolor}
\definecolor{lm_green}{RGB}{120, 162, 47}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\begin{document}
\newpagecolor{blue}
\thispagestyle{empty} % removes header and page number on this page; like Excel Diff page number
\colorbox{lm_green}{
\parbox[c]{0.98\linewidth}{
\fontsize{65pt}{80pt}\selectfont
\vspace*{2in}
\textcolor{white}{Data Graphs for Legal Management} \hspace{.3in} \\
\textcolor{white}{A competitive advantage for decisions} \hspace{.3in} \\
\vspace*{1in}
\textcolor{white}{\LARGE Rees W. Morrison, Esq.} \hspace{.3in} \\ %\large does not take an argument, re Carlisle
%\vspace*{.1in}
\textcolor{white}{\LARGE Release 1.0} \\
%\hfill \\
\par
}
}
\vspace*{2in}
\clearpage
\restorepagecolor
\end{document}
2.
\documentclass{book}
\usepackage[margin = 0.8in]{geometry}
\usepackage{afterpage} % if coloring only one page, like the cover, use this at end
% https://tex.stackexchange.com/questions/25137/how-to-change-the-background-color-only-for-the-current-page
\usepackage{pagecolor}
\usepackage{xcolor}
\definecolor{lm_green}{RGB}{120, 162, 47}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\newpagecolor{blue}
\thispagestyle{empty} % removes header and page number on this page; like Excel Diff page number
\colorbox{lm_green}{
\parbox[c]{0.98\linewidth}{
\fontsize{65pt}{80pt}\selectfont
\vspace*{2in}
\textcolor{white}{Data Graphs} \hspace{.3in} \\
\textcolor{white}{A competitive advantage for decisions} \hspace{.3in} \\
\vspace*{1in}
\textcolor{white}{\LARGE{Confused by LaTeX}} \hspace{.3in} \\
%\vspace*{.1in}
\textcolor{white}{\LARGE{Release 1.0}} \\
%\hfill \\
\par
}
}
\vspace*{2in}
\clearpage
\restorepagecolor
<<setup, echo = FALSE, message = FALSE, cache = FALSE>>=
source("C:/Users/Rees/Documents/R/Scripts/gcm.R")
opts_chunk$set(echo=F, warning=F, message=F, cache=T, fig.align='center', comment=NA)
@
\end{document}