Error occurred, creating Vignette in LateX style 2.0
2
0
Entering edit mode
Mattia ▴ 10
@mattia-9769
Last seen 5.5 years ago
Milano

Hi,

I created a package which I would submit in Bioconductor. I followed guidelines: regarding "code" I haven't got any errors or "warning" and each function seems to work perfectly. Then for each function, I created .Rd files, using Roxygen2. Again, no errors and no warning, when I "Build" and when I "Check".

However, I got errors when I tried to create vignettes in new Bioconductor LATEX Style 2.0.

I installed BiocStyle package, Miktek and Texlive for 'pdflatex'; I set the environment variable RSTUDIO_PDFLATEX=C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex.exe;  then I selected 'knitr' as Vignette Builder.

Since it's the first time I create a package, I used a small part of DESeq2.Rnw as example vignette. In particular, I adapted the first 50 lines (more or less). This is the content of 'myPackage.Rnw':

%\VignetteIndexEntry{Vignette of "myPackage" package}
%\VignettePackage{myPackage}
%\VignetteEngine{knitr::knitr}

% To compile this document
% library('knitr'); rm(list=ls()); knit('myPackage.Rnw')

\documentclass{article}

<<style, eval=TRUE, echo=FALSE, results="asis">>=
BiocStyle::latex2()
@

<<knitr, echo=FALSE, results="hide">>=
library("knitr")
opts_chunk$set(
  tidy=FALSE,
  dev="png",
  fig.show="hide",
  fig.width=4, fig.height=4.5,
  fig.pos="tbh",
  cache=TRUE,
  message=FALSE)
@

\author{first auth}
\affil{Center;}

\author{second auth}
\affil{Center;}

\author{third auth}
\affil{Center;}

\title{myPackage: this is my new package}

\begin{document}

\maketitle

\bibliography{library}

\end{document}

So, when I compile clicking on "Compile PDF" button, a .tex file is created but an error occurs when it tries to run pdflatex.exe on 'myPackage.tex':

output file: myPackage.tex

[1] "myPackage.tex"
Running pdflatex.exe on myPackage.tex...failed

Issues: 2 errors:

! LaTeX Error: File `C:/ProgramFiles/R/R-3.3.2/library/BiocStyle/resources/tex/Bioconductor2.sty' not found.

Of course, this is the same Error I obtain when I launch devtools::build():

"C:/PROGRA~1/R/R-33~1.2/bin/x64/Rcmd.exe" build "C:\Users\user\Desktop\myPackage" --no-resave-data --no-manual
* checking for file 'C:\Users\user\Desktop\myPackage/DESCRIPTION' ... OK
* preparing 'myPackage':
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Warning: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texify.exe" --quiet --pdf "myPackage.tex" --max-iterations=20 -I "C:/PROGRA~1/R/R-33~1.2/share/texmf/tex/latex" -I "C:/PROGRA~1/R/R-33~1.2/share/texmf/bibtex/bst"' had status 1
Error: running 'texi2dvi' on 'myPackage.tex' failed

LaTeX errors:
! LaTeX Error: File `C:/ProgramFiles/R/R-3.3.2/library/BiocStyle/resources/tex/Bioconductor2.sty' not found.

Bioconductor2.sty file is in that folder; so, what am I doing wrong?

Thanks in advance,

Mattia.

biocstyle vignettes build/check error latex • 3.4k views
ADD COMMENT
0
Entering edit mode

Is this specific to BiocStyle 2.0, or does it also occur with the lines below?

<<style, eval=TRUE, echo=FALSE, results="asis">>=
BiocStyle::latex()
@
ADD REPLY
0
Entering edit mode

Andrzej it's exactly the same:

! LaTeX Error: File `C:/ProgramFiles/R/R-3.3.2/library/BiocStyle/resources/tex/Bioconductor.sty' not found.

 

ADD REPLY
0
Entering edit mode

Ok, I see. It must be something specific to your system then, but I'm not sure what could be the problem here. BiocStyle is around for over 3 years now and we didn't receive any reports on similar problems in the past. Do you have a chance to test your package on another machine?
 

ADD REPLY
0
Entering edit mode

The file path looks suspicious, ' ProgramFiles' instead of 'Program Files' (which would probably cause LaTeX problems) or 'PROGRA~1'.

ADD REPLY
0
Entering edit mode

Good call Martin!

Mattia, can you maybe show us the header of the intermediate .tex file containing the relevant call to Bioconductor*.sty?

ADD REPLY
0
Entering edit mode

You are right Martin: it's strange. I'm going to check LateX options. Anyway: here my .tex file:

%\VignetteIndexEntry{Vignette of "myPackage" package}
%\VignettePackage{myPackage}
%\VignetteEngine{knitr::knitr}

% To compile this document
% library('knitr'); rm(list=ls()); knit('myPackage.Rnw')

\documentclass{article}\usepackage[]{graphicx}\usepackage[usenames,dvipsnames]{color}
%% maxwidth is the original width if it is less than linewidth
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
\makeatletter
\def\maxwidth{ %
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother

\definecolor{fgcolor}{rgb}{0.345, 0.345, 0.345}
\newcommand{\hlnum}[1]{\textcolor[rgb]{0.686,0.059,0.569}{#1}}%
\newcommand{\hlstr}[1]{\textcolor[rgb]{0.192,0.494,0.8}{#1}}%
\newcommand{\hlcom}[1]{\textcolor[rgb]{0.678,0.584,0.686}{\textit{#1}}}%
\newcommand{\hlopt}[1]{\textcolor[rgb]{0,0,0}{#1}}%
\newcommand{\hlstd}[1]{\textcolor[rgb]{0.345,0.345,0.345}{#1}}%
\newcommand{\hlkwa}[1]{\textcolor[rgb]{0.161,0.373,0.58}{\textbf{#1}}}%
\newcommand{\hlkwb}[1]{\textcolor[rgb]{0.69,0.353,0.396}{#1}}%
\newcommand{\hlkwc}[1]{\textcolor[rgb]{0.333,0.667,0.333}{#1}}%
\newcommand{\hlkwd}[1]{\textcolor[rgb]{0.737,0.353,0.396}{\textbf{#1}}}%
\let\hlipl\hlkwb

\usepackage{framed}
\makeatletter
\newenvironment{kframe}{%
 \def\at@end@of@kframe{}%
 \ifinner\ifhmode%
  \def\at@end@of@kframe{\end{minipage}}%
  \begin{minipage}{\columnwidth}%
 \fi\fi%
 \def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
 \colorbox{shadecolor}{##1}\hskip-\fboxsep
     % There is no \\@totalrightmargin, so:
     \hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
 \MakeFramed {\advance\hsize-\width
   \@totalleftmargin\z@ \linewidth\hsize
   \@setminipage}}%
 {\par\unskip\endMakeFramed%
 \at@end@of@kframe}
\makeatother

\definecolor{shadecolor}{rgb}{.97, .97, .97}
\definecolor{messagecolor}{rgb}{0, 0, 0}
\definecolor{warningcolor}{rgb}{1, 0, 1}
\definecolor{errorcolor}{rgb}{1, 0, 0}
\newenvironment{knitrout}{}{} % an empty environment to be redefined in TeX

\usepackage{alltt}

\RequirePackage{C:/Program Files/R/R-3.3.2/library/BiocStyle/resources/tex/Bioconductor}

\AtBeginDocument{\bibliographystyle{C:/Program Files/R/R-3.3.2/library/BiocStyle/resources/tex/unsrturl}}

\author{first auth}
\affil{Center;}

\author{second auth}
\affil{Center;}

\author{third auth}
\affil{Center;}

\title{myPackage: this is my new package}
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\begin{document}

\maketitle

\bibliography{library}

\end{document}

Here, path to .sty seems ok.

Thanks again.

 

ADD REPLY
0
Entering edit mode

Thanks Mattia! Can you please check whether substituting the line loading Bioconductor.sty by any of the following two lines circumvents the problem?

\RequirePackage{"C:\Program Files\R\R-3.3.2\library\BiocStyle\resources\tex\Bioconductor"}
\RequirePackage{{C:\Program Files\R\R-3.3.2\library\BiocStyle\resources\tex\Bioconductor}}
ADD REPLY
0
Entering edit mode

No Andrzej, nothing changes. But I tried to comment in .tex file:

%\RequirePackage[]{C:/Program Files/R/R-3.3.2/library/BiocStyle/resources/tex/Bioconductor2}

%\AtBeginDocument{\bibliographystyle{C:/Program Files/R/R-3.3.2/library/BiocStyle/resources/tex/unsrturl}}

and 

%\author{first auth}

%\affil{Center;}

%\author{second auth}
%\affil{Center;}

%\author{third auth}

%\affil{Center;}

 

And TexLive creates PDF file.

ADD REPLY
1
Entering edit mode
Andrzej Oleś ▴ 750
@andrzej-oles-5540
Last seen 4.1 years ago
Heidelberg, Germany

To address the problem of file paths containing spaces I've added an option in BiocStyle v2.3.28  to copy the supporting files to the vignette directory and refer to them by relative paths. To enable it, use

BiocStyle::latex2(relative.path = TRUE)

 

 

ADD COMMENT
0
Entering edit mode

I installed this version and it works perfectly!.

Thanks again Andrzej!

Mattia.

ADD REPLY
0
Entering edit mode
Mattia ▴ 10
@mattia-9769
Last seen 5.5 years ago
Milano

Following David Carlisle suggestion, in TeX - LaTeX Stack Exchange Furum, now the problem seems to be solved; 

  • I set a new Path in "Root" panel of Miktek Settings:

C:\Program Files\R\R-3.3.2\library\BiocStyle\resources

  • Then, I modified two lines in 'myPackage.Rnw' :
\RequirePackage[]{Bioconductor2}
\AtBeginDocument{\bibliographystyle{unsrturl}}

instead of

<<style, eval=TRUE, echo=FALSE, results="asis">>=
BiocStyle::latex2()
@
  • I used Sweave instead of knitr, so:
%\VignetteEngine{knitr::knitr}

<<knitr, echo=FALSE, results="hide">>=
library("knitr")
opts_chunk$set(
  tidy=FALSE,
  dev="png",
  fig.show="hide",
  fig.width=4, fig.height=4.5,
  fig.pos="tbh",
  cache=TRUE,
  message=FALSE)
@
  •  And finally I compiled the document.

Now, PDF is generated without any errors or warnings.

Mattia.

ADD COMMENT
0
Entering edit mode

Please note that this solution is not portable and will only work on machines which have the directory containing Bioconductor2.sty added to the LaTeX PATH. In particular, your vignette will fail to compile on Bioconductor builders once you submit the package for review.

See my answer below for a more robust approach.

ADD REPLY

Login before adding your answer.

Traffic: 472 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6