-
-
Notifications
You must be signed in to change notification settings - Fork 969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to specify LaTeX dependencies in knitr_meta #647
Conversation
if (has_latex_dependencies(knit_meta)) { | ||
all_dependencies <- if (is.null(format_deps)) list() else format_deps | ||
all_dependencies <- append(all_dependencies, flatten_latex_dependencies(knit_meta)) | ||
filename <- tempfile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific rmarkdown
way of creating a temporary file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No there isn't anything special required here.
Could you add a NEWS item for this feature? Thanks! |
@yihui This looks good to me, could you review as well? |
@@ -56,6 +56,9 @@ default definition or R Markdown. See the \code{\link{rmarkdown_format}} for | |||
additional details.} | |||
|
|||
\item{pandoc_args}{Additional command line options to pass to pandoc} | |||
|
|||
\item{extra_dependencies}{Additional function arguments to pass to the | |||
base R Markdown HTML output formatter \code{\link{html_document_base}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to document this argument explicitly in roxygen instead of relying on @inheritParams html_document
This looks good overall. My only concern is that unlike HTML, LaTeX is so very fragile and this approach could easily fail, e.g. you cannot Another possibly useful feature is like the |
…ra_dependencies` as an argument.
Following @yihui's advice, taking care of all the possibilities is a bit messy right now.
I have addressed all the code comments. Regarding @yihui comment about LaTeX fragility, I totally agree with you, but there is little I can do. Other packages that want to use this feature will have to cooperate in order to avoid compatibility issues. Given that it seems all right to you, I would rather offer a simple initial implementation than trying to address all possible issues without having practical use cases. |
@yihui Feel free to merge once you've reviewed all of the follow up commits. |
Allow to specify LaTeX dependencies in knitr_meta; closes yihui/knitr#1184
Something is unclear about this. I'm building a package with a custom thesis template and want to include a custom .sty file in the pdf_document. My function, afit_thesis.R, contains a call to pdf_document in which I've provided the argument extra_dependencies=latex_dependency('myPackage') where 'myPackage' has been the name of the package and the path to the package using After reading this pull request, the rmarkdown documentation and the online documentation for pdf documents, it is not clear as to where the custom Latex package should be stored or how it should be called to ensure it is included in a .tex file. |
@Auburngrads Typically I just put them in a .tex file, and include the .tex file in the preamble via the output:
pdf_document:
includes:
in_header: your-preamble.tex |
@yihui By 'them' I assume you mean relative paths to the .sty files. Per the documentation for Perhaps my problem is trying to reference an absolute file path with |
This patch allows third party packages to specify LaTeX package names and options to be inserted in the final LaTeX header.
Why is it needed
At least the
condformat
package needs to add\usepackage[table]{xcolor}
to the.tex
preamble. Currently the only way to do that is to addincludes: in_header: filename
in the yaml header of each of the files to be rendered. A package can not add by itselfLaTeX
dependencies.Proposed solution
Based on the discussion started here, I wrote this patch. Summarizing:
latex_dependency
that can be used by themeta
argument in knit_print as described here to add LaTeX package dependencies. A use case is found here..tex
file that is added to the args passed to pandoc usingincludes_to_pandoc_args
. The dependency list compilation is based on how it is done for the HTML dependencies.Contributor agreement
Comments
rmarkdown
.