So ändern Sie den Knitr-Ausgabeblock

So ändern Sie den Knitr-Ausgabeblock

Ich weiß, dass es möglich ist, die Ausgabe eines knitrCodeblocks so zu optimieren, dass sie wie gewünscht aussieht. Mein Problem tritt jedoch bei Verwendung des parskipPakets auf. Das parskipPaket fügt unterhalb der Codeausgabe etwas zusätzlichen Platz hinzu, was nicht besonders gut aussieht. Hier ist eine minimale .RnwDatei.

\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}

Antwort1

Dies ist keine elegante Antwort, aber Sie können den überschüssigen Platz durch die Einbeziehung von negativem vertikalen Raum „beheben“. Siehe den geänderten Code.

\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}

verwandte Informationen