3

I am currently trying to create a landscape document using r markdown. Since I also want the header to be in landscape, I have the following mystyles.sty document:

\usepackage[landscape]{geometry}
\usepackage{float}
\usepackage{subfigure}
\usepackage[table]{xcolor}
\usepackage{,pdflscape}

which is called in the header of my main document:

---
title: "Transition Matrix Report for 2015-01-20"
author: "Paul Lintilhac"
date: "Monday, February 2, 2015"
output:
  pdf_document:
    includes:
      in_header: mystyles.sty
---

however, when I try to knit the pdf, I get the error:

 ! LaTeX Error: Option clash for package geometry.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.62 \usepackage

pandoc.exe: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc"     TransitionMatrix.utf8.md --to latex --from     markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output TransitionMatrix.pdf --template "C:\PROGRA~1\R\R-31~1.2\library\RMARKD~1\rmd\latex\default.tex" --highlight-style tango --latex-engine pdflatex --include-in-header mystyles.sty --variable "geometry:margin=1in"' had status 43 
Execution halted

I have checked many forums online, and they all seem to say that this error occurrs because I have tried to load a package with options twice. But clearly this is not the case. I have checked line 62 in the tex document produced by r markdown, and it is the line after calling usepackage[landscape]{geometry}. Getting rid of the other packages in mystyles.sty has no effect, however, when I go to the top of the tex document, I can see several other packages that are getting loaded automatically, as you can see at the top of the tex document copied below:

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\usepackage{fixltx2e} % provides \textsubscript

\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
\usepackage[margin=1in]{geometry}


\usepackage[landscape,width=15in,height=11.5in,top=.5in,bottow=.5in]{geometry}
\usepackage{float}
\usepackage{subfigure}
\usepackage[table]{xcolor}
\usepackage{,pdflscape}

I get the same error if I remove any of these except for \usepackage{ifxetex,ifluatex} , which gives a different error.

What is going wrong here and how can I fix? Would really appreciate your help as I have been trying to get this stupid formatting correct for hours.

Best,

-Paul

  • Extra comma?! \usepackage{,pdflscape} – Sigur Feb 2 '15 at 23:52
  • thanks for the comment, but as I said, removing the other packages from mystyles.sty has no effect unfortunately. – Paul Feb 2 '15 at 23:53
  • Please post a single complete example that generates the error. We can't debug code we can not see. Start with a copy of the first 62 lines of the document and delete anything you can while still generating the error, then post the result. – David Carlisle Feb 2 '15 at 23:53
  • sure, I just posted the minimum code that produces the error. I now see that there is a conflicting import of the geometry package, but I don't know what to do because this code is being automatically produced by r markdown. – Paul Feb 2 '15 at 23:58
  • 1
    If you run latex on a document that has two \usepackage with the same package, by any normal reading you loaded the package twice. it may be you used a tool to generate a bad document but to be honest that's off topic for this site. – David Carlisle Feb 3 '15 at 0:12
5
\usepackage[margin=1in]{geometry}

and

\usepackage[landscape,width=15in,height=11.5in,top=.5in,bottow=.5in]{geometry}

look like loading twice to me.

  • thank you for pointing that out. I realize that it is being loaded twice, but I did not do that myself -- it is just happening automatically. Any advice on how to stop that from happening? – Paul Feb 3 '15 at 0:05
  • 1
    @PaulNo idea sorry, I don't have experience of that generator so can't say whether you are giving it bad input, or it is doing it on its own so it's a bug. If you have access to the document preamble and can cause geometry to be loaded earlier, load it with all the options (I assume bottow is a typo for bottom by the way) then both the current \usepackage will be ignored without error as they are using subsets of the initial option set. – David Carlisle Feb 3 '15 at 0:10
  • @Paul: Your editor saw something shiny, was distracted, and then it magically thought to call geometry with a varied number of options... yes, so says my crystal ball Jeffrey... More serious though: your error points to line 62 as being a problem, while the minimal code doesn't have 62 lines. Why is that? – Werner Feb 3 '15 at 0:39
  • 2
    @Paul: As pandoc seems to load geometry you could simply write in your own style \geometry{landscape,width=15in,height=11.5in,top=.5in,bottom=.5in} to change the settings. – Ulrike Fischer Feb 3 '15 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.