When my colleague and I run the same Rmd file on our respective computers they produce different .tex files. This is a problem, because the tex-file my computer produces doesn't compile. Apparently there is some invisible local setting that is different between our computers but what could it be? I updated all the Rpackages I use but to no avail.
The Rmd file starts with
output:
bookdown::pdf_document2:
keep_tex: yes
toc: false
And both of us compile it by simply hitting the knit-button in Rstudio.
Noticeable differences in the tex-files are:
extra linebreaks in different places
a line that is commented out in the rmd-file (<!-- blabla -->) appears in my tex-file, not in his, but some other out-commented lines appear in neither (as they should)
at the end of lines in tables there is a \strut inserted in my tex-file but not in his
Section heads read \hypertaget{blabla} in his file but not mine
For none of these difference I can find any place in the Rmd-file where any choice w.r.t to this is made - apparently some local settings file I am not aware of is used in the process??
Please let me know if you need more information.
EDIT: we found a partial answer and full solution, but I am still interested in what the underlying mechanism is. It turned out that I was using an older version of Rstudio. (It took me long to find that out because the check for updates tool in Rstudio kept telling me that I was using the newest version, but that is a separate issue.) Using the same version of Rstudio we get the same result.
The translation from Rmd to tex has multiple steps:
All the code chunks are extracted and executed via knitr, resulting in a md file.
The md file is translated to tex via pandoc.
For most people pandoc comes bundled with RStudio. So when you updated that, you got a more recent pandoc version. You can test for the used pandoc version with rmarkdown::pandoc_version().
Related
I need to compile a .tex file twice with django_tex in order for the table of contents to load correctly. Is there a way to tell the interpreter in django_tex to run the compiler twice (I use pdflatex)??
Code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\tableofcontents
\section{Introduction}
Introduction text.
\section{Second section}
Second section text.
\end{document}
django_tex seems to support latexmk, which will (amongst many other useful things, like running bibliography tools) automatically determine the required number of *tex runs.
To use this, you can follow the advice from https://github.com/weinbusch/django-tex/pull/5#issuecomment-447030408 and add
LATEX_INTERPRETER='latexmk -pdf'
to your settings.py.
I'm creating pdf versions of html slides generated from R markdown files. I've come across a puzzling behaviour. When I run pagedown::chrome_print on the html with output specified as xaringan::moon_reader, the operation fails with the timeout message:
Error in force(expr) : Failed to generate output in 30 seconds (timeout)
Here is an example of a call to convert such a xaringan html file which produces this timeout error on my machine:
pagedown::chrome_print("https://stat540-ubc.github.io/lectures/lectures_2020/lect09_MultipleTesting.html")
The Rmd source for this html is located here. If I increase the timeout argument of chrome_print to something very large (several thousand), the operation appears to take a lot of resources (computer fans turn on, machine becomes hot), but the pdf output is eventually produced. However, if I instead change the output to slidy_presentation in the Rmd instead of xaringan::moon_reader, chrome_print runs successfully on the html and produces a pdf in just a few seconds (with no change to the default timeout argument).
I have the same issue with other slide decks that I have created with a similar template to the one I linked above, but this doesn't happen with every xaringan html file. For example, I am able to use chrome-print to successfully convert this xaringan html file to pdf (with no change to the default timeout argument):
pagedown::chrome_print("https://annakrystalli.me/talks/xaringan/xaringan.html")
Other things I tried:
I installed decktape and used the xaringan::decktape on the xaringan html file, which also produced a timeout error. Though I'm not sure how to increase the time using this method, so I don't know if it would eventually work if given enough time.
I tried using the latest versions of Google Chrome and Chromium with the chrome_print function and got the same results as described above. I'm using Mac OSX 10.15.5.
I would like to stick with xaringan html slides as they have some features I prefer. However, the current method of conversion to pdf is not sustainable for me since I will need to convert many similar htmls, as well as update them periodically. If anyone has come across this or can suggest what might be causing this extreme slowdown when converting my xaringan htmls to pdfs, I'd appreciate your input.
I am using the rmarkdown with the rshiny for generating word file reports. I am using the R studio-server for development. On executing the rshiny application, it halts due to some error in the one of the rmarkdown.
The error says...
Quitting from lines 11-486 (/home/KS127/dev/shiny_apps/pashiny/inst/shiny/dataframe_source.Rmd)
Quitting from lines NA-486 (/home/KS127/dev/shiny_apps/pashiny/inst/shiny/dataframe_source.Rmd)
It's providing the line numbers which are not useful to identify the root cause. Adding print statements are also not useful as I am generating the word file report, until and unless the complete .Rmd doesn't get successfully executed, I won't be able to see print statements output.
I tried changing the rmarkdown output setting from chunk output inline to chunk output to console as mentioned here as well but it is of no use.
Is there any way to print the .Rmd file print statements or the output to the console or is there any way to debug the .Rmd file?
In addition to my comment above, Abhinandan, I've recently stumbled across a new package, called testrmd.
Although it is new, it seems to work with a number of different test packages and provides a useful front-end for Rmarkdown documents. (I'm certainly going to use it.)
You might want to check it out. Here's the link: https://github.com/ropenscilabs/testrmd.
I hope this helps you.
See My .Rmd file becomes very lengthy. Is that possible split it and source() it's smaller portions from main .Rmd?
That's what I do. -
Split your code chunks in separate files and add them one by one
I recently updated Doxygen, and found that latex has become very unhappy with the generated .tex files - many complaints about 'Undefined control sequence'. These were associated with instances of '\+' inserted seemingly at random into text. If I just brute force removed all instances of '\+' from the generated .tex files, pdflatex was able to finish successfully, and I got a reasonable looking document.
I then poked around a little in the Doxygen source, and found that util.cpp seemed to be responsible for emitting the '\+' sequence, and that it did so when a boolean called insideTabbing was not set. This seemed kind of odd to me, and as an experiment, changed the sense of the test wherever it was performed. When I run with the modified doxygen, the generated code seems to be fine.
So, is there some setting in my Doxyfile that I failed to use, and which would have prevented the behavior I've been seeing?
The comment about defining newcommand provided the answer to my problem. In my Doxygen configuration file, LATEX_HEADER is given a file name as a value. The contents of that file end up overriding/replacing some of the content that usually gets generated for refman.tex. Once I incorporated \newcommand{\+}{\discretionary{\mbox{\scriptsize$\hookleftarrow$}}{}{}} into my header file, pdflatex was able to run successfully to completion.
I have written a program which exports my Pandas DataFrame to a csv as well as an excel file. However, the problem I am facing is that, randomly, the export function to both the file formats does not work, resulting in me seeing an error stating "No such File Path or Directory".
My code is as follows:
frame3.to_csv('C:/Users/Downloads/ABC_test.csv',index=False)
writer = pd.ExcelWriter('C:/Users/Downloads/ABCD.xlsx', engine='openpyxl')
frame3.to_excel(writer, sheet_name='Sheet1')
writer.save()
The major issue is that this code works sometimes and sometimes it does not! Going by what others have posted here, I tried to add the output directory by the use of
pth1 = os.path.join(r'C:/Users/Downloads/FinalProgram/', output_filename)
frame3.to_csv(pth1)
Sadly, this has no effect on this stubborn error. Would appreciate any help / insights possible on the matter.
Forgot to update - I figured a way around this particular problem:
Simply set the working directory for the program to be the output directory (as depicted by the command below), before the calling the 'to_csv' function.
os.chdir('F:/Codelah/')
On a side note, this was an issue I primarily faced on Windows OS - Ubuntu worked like a charm and did not require this workaround!
Hope this helps