1

I am writing a vignette for a package intended to be submitted to CRAN. One problem I have is that some of the functions and their input parameters can become so long that their example code extends off the page.

I worry this is a meticulous problems with LaTeX as I have had it happen before many times. However, I would like all the example code to be visible for the users. Fortunately, none of the example code I put in the vignette should be run automatically. Hence, I have an eval=FALSE expression in the R chunks.

As a (possible hack?) of a troubleshooting solution, I have just manually inserted a line break in the code that will not be run anyway. This allows the example code to not run off the page, and does not effect the functionality of the example code that is not run anyway automatically.

Is this "solution" okay with CRAN standards? If not, what other solution may I try to consider to solve this problem?

Below is my MWE:

\documentclass{article}
\setlength{\parindent}{0pt} % Remove indent at new paragraphs
\setcounter{secnumdepth}{0}  % Remove section numbering at certain depth
\usepackage[round,sort]{natbib}
\usepackage{fixltx2e}
\usepackage{graphicx}   % For external pictures
\usepackage{float}
\usepackage{subfig} % Add subfigures within figures
\usepackage{verbatim}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
\usepackage{amssymb,amsbsy,amsmath}
\usepackage{epsfig}
\usepackage[left=3cm,top=3cm,bottom=3.5cm,right=3cm]{geometry} % For easy document margins
\usepackage{fancyhdr} % For customization of header/footer
\usepackage{adjustbox}
\numberwithin{equation}{section} % Equation numbers relative to sections
\begin{document}
\sloppy

<<include=FALSE>>=
library(knitr)
opts_chunk$set(
concordance=TRUE
)
@

<<echo=FALSE>>=
rm(list=ls())
library(knitr)
@ 

\section{Examples}

\subsection{Easy Example}

Here is an example you can run below:

<<eval=FALSE>>=
example1 = function1("it does not surpass the line")
@

Here is a second example you can run below. Unfortunately, you cannot even see teh whole example code because it runs off the page:

<<eval=FALSE>>=
example2 = function2(input1="this example", input2 = "has a lot of inputs", input3="which makes it impossible", input4 = "to fit on the same line")
@

Can I fix this second example by forcing a break as such?:

<<eval=FALSE>>=
example2 = function2(input1="this example", input2 = "has a lot of inputs",
input3="which makes it impossible", input4 = "to fit on the same line")
@

\end{document}
  • maybe try `tidy=FALSE` in the chunk options? – Ben Bolker Nov 07 '15 at 19:47
  • @BenBolker Thank you for the reply. I changed my second R chunk (the problematic one) to <>=. However, the text still ran off the page. –  Nov 07 '15 at 20:03

0 Answers0