Rmarkdown does not recognize pandoc filter - filter

I would like to call a pandoc filter (this one) from rmarkdown/RStudio. However, pandoc seems not to recognize the filter. I've handed over the filter in the YAML header. Consider this rmd file:
---
title: "test"
output: pdf_document
header-includes:
- \usepackage{xspace}
pandoc_args:
- --filter
- pandoc-filter/typography.py
---
test
s.S.
The knitting output shows no sign that the filter was handed over to pandoc:
/usr/local/bin/pandoc +RTS -K512m -RTS test_typography-py.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output test_typography-py.pdf --template /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --variable 'geometry:margin=1in'
The rendered pdf file does not show the effects of the filter, see image
(The effect of the filter is to render a thin space between phrases such as "z.B." or "e.g.".)
What can I do to get this filter run by pandoc via rmarkdown (preferably using the YAML header)?

I just realized (thanks to #NMarkgraf) that I had an intendation error. The correct intendation in YAML is this:
---
title: "test"
header-includes:
- \usepackage{xspace}
output:
pdf_document:
pandoc_args:
- --filter
- typography.py
---
Then it works - the filter is recognized.

Related

Basic ImageMagic disconnect: converting plain ASCII.txt file into image file ASCII.jpg - ending up with errors

I have been trying to convert a plain text file (containing ASCII sentences / lines) into an JPEG image - not caring about any formats or styles - just a first try - keen on quick results:
After half a day trials and errors in all variations - all failing with the below (or similar) errors - and nearly going mad I have solved the following error message :
...
convert-im6.q16: not authorized `#a.txt' # error/property.c/InterpretImageProperties/3516.
I have gotten the wanted result when I have deactivitated
/etc/ImageMagick-6/policy.xml
into
/etc/ImageMagick-6/_policy.xml
Can somebody explain - please - what the magic behind is with this (deactivated) file ???
And please - being sure this file should become re-activated as it is by default - what do I need to change instead (in the file ???)
Thanks in advance with BR
If you are not on a shared server, you can edit your ImageMagick policy.xml file to give read|write permissions for the use of "#".
I suspect the defaults are still "none" for the use of "#" even if you disable the policy.xml file.
Then you can read a text file (in this case ipsum_lorem.txt) :
convert -size 1000x -font arial -pointsize 28 caption:"#ipsum_lorem.txt" x.jpg
or
cat ipsum_lorem.txt | convert -size 1000x -font arial -pointsize 28 caption:"#-" x.jpg
and the result should be:

Latex not opening png and windows not being able to generate bb

I'm using TexMaker (on Windows 10), using the pdflatex (F6) and yet I can't open the PNG file in the folder of my .tex
\usepackage{graphicx}
\begin{document}
\begin{figure}[h!]
\includegraphics[width=\linewidth]{File.png}
\end{figure}
\end{document}
so I tried to create an bb file from the PNG. I opened cmd at the folder and typed:
ebb File.png
ebb: file not writable for security reasons: File.bb
ebb: fatal: Unable to open output file File.bb
When clicking in the properties and security of File.png I see that my user both: is the owner of the folder and has all permissions set in (even tho I cannot uncheck any of the permissions I have, weirdly).
The folder which I'm working on has that black square marked on the "read only" attribute (in properties). Which I can't quite keep unchecked even tho I'm the owner of it. What is wrong?
EDIT: Here's what happens when I click on show permissions (>properties >security >advanced >show permissions) my user is the owner.
I can't click on anything even tho I'm the owner.
Edit, the logfile:
LOG FILE :
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.10) (preloaded format=pdflatex 2020.10.24) 25 OCT 2020 10:47
entering extended mode
**./test.tex
(test.tex
LaTeX2e <2020-10-01> patch level 1
L3 programming layer <2020-10-05> xparse <2020-03-03>
("C:\Program Files\MiKTeX\tex/latex/base\article.cls"
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
("C:\Program Files\MiKTeX\tex/latex/base\size12.clo"
File: size12.clo 2020/04/10 v1.4m Standard LaTeX file (size option)
)
\c#part=\count175
\c#section=\count176
\c#subsection=\count177
\c#subsubsection=\count178
\c#paragraph=\count179
\c#subparagraph=\count180
\c#figure=\count181
\c#table=\count182
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
("C:\Program Files\MiKTeX\tex/latex/graphics\graphicx.sty"
Package: graphicx 2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX\tex/latex/graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV#toks#=\toks15
)
("C:\Program Files\MiKTeX\tex/latex/graphics\graphics.sty"
Package: graphics 2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
("C:\Program Files\MiKTeX\tex/latex/graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Program Files\MiKTeX\tex/latex/graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 105.
("C:\Program Files\MiKTeX\tex/latex/graphics-def\pdftex.def"
File: pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
))
\Gin#req#height=\dimen139
\Gin#req#width=\dimen140
)
("C:\Program Files\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def"
File: l3backend-pdftex.def 2020-09-24 L3 backend support: PDF output (pdfTeX)
\l__kernel_color_stack_int=\count183
\l__pdf_internal_box=\box47
) (test.aux)
\openout1 = `test.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3.
LaTeX Font Info: ... okay on input line 3.
("C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count184
\scratchdimen=\dimen141
\scratchbox=\box48
\nofMPsegments=\count185
\nofMParguments=\count186
\everyMPshowfont=\toks16
\MPscratchCnt=\count187
\MPscratchDim=\dimen142
\MPnumerator=\count188
\makeMPintoPDFobject=\count189
\everyMPtoPDFconversion=\toks17
) ("C:\Program Files\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-base.sty"
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.
)
<semirreta.png, id=1, 368.1253pt x 99.37125pt>
[1{C:/Users/JoaoV/AppData/Local/MiKTeX/pdftex/config/pdftex.map}] (test.aux) )
Here is how much of TeX's memory you used:
1167 strings out of 480236
17436 string characters out of 2890433
280939 words of memory out of 3000000
17769 multiletter control sequences out of 15000+200000
535555 words of font info for 31 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
60i,4n,66p,199b,236s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/Program F
iles/MiKTeX/fonts/type1/public/amsfonts/cm/cmtt12.pfb>
Output written on test.pdf (1 page, 13448 bytes).
PDF statistics:
15 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
6 words of extra memory for PDF output out of 10000 (max. 10000000)
I made a little test:
the real image is suposed to be these two lines: https://ibb.co/yYQCfnd
Remove the draft option, this prevents images from showing up

R markdown Stargazer: knit to pdf issue: Executed haulted

While trying to knit .rmd file to pdf, if code chunks has stargazer function, the file is not knitting to pdf format. I have several tables (both long and short) with combination of regression output via stargazer in latex format but none of them are converting to pdf. I am using MikTeX as LaTeX distribution. I have used following code (as an example)
stargazer(pre.ols.sp01SIOI,pre.ols.sp02SIOI,pre.ols.sp03SIOI,pre.ols.sp04SIOI,
post.ols.sp01SIOI,post.ols.sp02SIOI,post.ols.sp03SIOI,post.ols.sp04SIOI,
style = "qje", type = "latex", header=FALSE, title = "Regression Analysis").
I am getting the following error.
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7440 64-bit) entering extended mode
I was unable to find any missing LaTeX packages from the error log Paper1.v7_11Jun2020.log.
Error: LaTeX failed to compile Paper1.v7_11Jun2020.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips.
In addition: Warning messages:
1: In readLines(log) : line 888 appears to contain an embedded nul
2: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
3: In readLines(log) : line 888 appears to contain an embedded nul
4: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
5: In readLines(log) : line 888 appears to contain an embedded nul
6: In readLines(log) :
incomplete final line found on 'Paper1.v7_11Jun2020.log'
Execution halted
I have followed the debugging tips mentioned on the yihui.org. But still no luck.
I have also tried to assign the stargazer output and then use kable() and still
it's not working. Moreover, I have tried to using landscape style.
I appreciate any assistance with the issue.
Thanks
Edit: The YAML header
title: XXX
documentclass: article
date: "r format(Sys.Date(),'%d %B, %Y')"
output:
pdf_document:
df_print: paged
fig_caption: yes
highlight: tango
number_sections: yes
citation_package: natbib
keep_tex: yes
bibliography: library.bib
header-includes:
-\usepackage{amsmath}
-\usepackage[utf8]{inputenc}
-\usepackage{autobreak}
-\usepackage{setspace}
-\usepackage{hyperref}
-\usepackage[authoryear]{natbib}
-\usepackage{caption}
-\usepackage{babel
-\usepackage{multirow}
-\usepackage{pdflscape}
-\usepackage{dcolumn}
-\usepackage{rotating}

rmarkdown fails using googleVis - pandoc does not support https - works on RStudio

I have a Rmarkdown document that uses googleVis library.
It works fine on RStudio. I just press "Knit HTML" button and "voilá": I get a beautiful HTML.
However, when I try to generate on the command line, I get an error in Pandoc.
I just run:
Rscript --verbose -e 'script.R'
Where script.R is:
rmarkdown::render("inputFile.Rmd", output_dir=file.path("/path/to/my/dir"), output_file="outfile.html", encoding="UTF-8");
The error I get is this:
(.....)
output file: 5c86eb19-d29f-4ac6-ac35-87e72fb42bbd2787560825121738853.knit.md
/opt/local/bin/pandoc +RTS -K512m -RTS 5c86eb19-d29f-4ac6-ac35-87e72fb42bbd2787560825121738853.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output /Users/rodrigo/Documents/Nitryx/Technical/Projects/NitroERP/repository/5c86eb19-d29f-4ac6-ac35-87e72fb42bbd.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 2 --variable toc_float=1 --variable toc_selectors=h1,h2 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --template /opt/local/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --number-sections --variable 'theme:bootstrap' --include-in-header /var/folders/dd/y3fs2t5j1n3fg8nfq1syrzym0000gn/T//RtmpTjWUT6/rmarkdown-str301943f9d761.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/opt/local/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight --variable navigationjs=/opt/local/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/navigation-1.0
Fetching https://www.google.com/jsapi?callback=displayChartGaugeID30195c82acb7...
pandoc: Failed to retrieve https://www.google.com/jsapi?callback=displayChartGaugeID30195c82acb7
user error (https not supported)
Error: pandoc document conversion failed with error 61
Execution halted
Note the:
pandoc: Failed to retrieve https://www.google.com/jsapi?callback=displayChartGaugeID30195c82acb7
user error (https not supported)
But it works on RStudio...
Can you help?
RStudio probably uses a different pandoc version than the one you get on the command line... (see e.g. this issue.)
Try installing the newest pandoc and make sure you're using that with pandoc -v

How to use RStudio to write a RMarkdown file with Stata commands?

My problem is explained in the title. I've tried compiling a sample .Rmd I found here: http://www.ssc.wisc.edu/~hemken/Stataworkshops/Stata%20and%20R%20Markdown/
in addition to looking up various resources online to no avail. While my resource, Doug, was able to compile an RMarkdown, I am getting an error for the MWE below.
The MWE is:
---
title: "Stata and R Markdown (Windows)"
author: "Doug Hemken"
date: "July 2015"
output:
html_document:
toc: yes
---
```{r, echo=FALSE, message=FALSE}
require(knitr)
statapath <- "/Applications/Stata/Stata.app"
opts_chunk$set(engine="stata", engine.path=statapath, comment="")
```
### Descriptive Statistics
A simple example.
```{r}
sysuse auto
summarize
```
The output/error from the RStudio console is:
processing file: stata.Rmd
|................ | 25%
ordinary text without R code
|................................ | 50%
label: unnamed-chunk-1 (with options)
List of 2
$ echo : logi FALSE
$ message: logi FALSE
Loading required package: knitr
|................................................. | 75%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-2
running: /Applications/Stata/Stata.app -q -b stata47b9d14e1c.do
Quitting from lines 20-22 (stata.Rmd)
Error in engine(options) :
sh: /Applications/Stata/Stata.app: is a directory
Calls: <Anonymous> ... process_group.block -> call_block -> block_exec -> in_dir -> engine
In addition: Warning message:
running command ''/Applications/Stata/Stata.app' -q -b stata47b9d14e1c.do 2>&1' had status 126
Execution halted
The page you link to points to this page. There, it is written: "For example, if Stata is installed in /Applications/Stata/, then the path to the Stata executable is /Applications/Stata/Stata.app/Contents/MacOS/", and they give appropriate links for all different flavours of Stata. Also, you need to refer to the executable, not the folder where it is located. If I change your MWE as below, everything works for me (note that I use Stata-SE; you might need to change this for your system).
---
title: "Stata and R Markdown (Windows)"
author: "Doug Hemken"
date: "July 2015"
output:
html_document:
toc: yes
---
```{r, echo=FALSE, message=FALSE}
require(knitr)
statapath <- "/Applications/Stata/StataSE.app/Contents/MacOS/stata-se"
opts_chunk$set(engine="stata", engine.path=statapath, comment="")
```
### Descriptive Statistics
A simple example.
```{r}
sysuse auto
summarize
```

Resources