我知道可以调整knitr
代码块的输出,使其看起来符合您的要求。我在使用该parskip
包时遇到了问题。该parskip
包在代码输出下方添加了额外的空间,看起来不太好。这是一个最小.Rnw
文件。
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{parskip}
\begin{document}
\setlength{\parindent}{0in}
Some text above chunk
<<echo=TRUE>>=
2 + 2
@
Some text below. The space above this is too big when using the \texttt{parskip} package.
Some text below. The space above this is too big when using the \texttt{parskip} package.
Some text below. The space above this is too big when using the \texttt{parskip} package.
A nice space between paragraphs.
\end{document}
答案1
这不是一个优雅的答案,但您可以通过包含负垂直空间来“修复”多余的空间。请参阅修改后的代码。
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
%\usepackage{parskip}
\begin{document}
\setlength{\parindent}{0in}
Some text above chunk
<<echo=TRUE>>=
2 + 2
@
\vspace{-1em} %%% this moves the following text up the height of an 'm'
Some text below. The space above this is too big when using the \texttt{parskip} package.
Some text below. The space above this is too big when using the \texttt{parskip} package.
Some text below. The space above this is too big when using the \texttt{parskip} package.
A nice space between paragraphs.
\end{document}