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}

관련 정보