Как изменить выходной фрагмент knitr

Как изменить выходной фрагмент knitr

Я знаю, что можно настроить вывод 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}

Связанный контент