pandoc 2.1 task-list do not render in docx - docx

Is there a way to create a task-list that prints in docx format? I am using the [ ] task-list and [x] completed-task syntax, with the following filters:
-r markdown+smart+implicit_figures+table_captions+pipe_tables+latex_macros+compact_definition_lists+subscript+superscript+yaml_metadata_block+raw_tex+fenced_code_attributes+line_blocks+backtick_code_blocks+fenced_code_blocks+link_attributes+tex_math_dollars+native_spans
This seems to working html (when I view it via the preview app Marked2, but I cannot get it to work when converting from markdown to docx.
Any help is greatly appreciated. Thanks.

Plain pandoc does not support task lists. However, you can use a filter to add support. Have a look at the task-list filter in the semi-official filter collection. You can use it by adding it to you directory and calling pandoc with an additional --lua-filter=task-list.lua parameter.

As of pandoc 2.6, task lists are supported.

If you use an older version (e.g. 2.2.1 currently in Debian Buster), you can use this workaround with a Latex math environment:
- $\Box$ Task 1
- $\Box$ Task 2
Alternatively, you can use $\square$ as well, but this renders smaller boxes for me. This only works for unchecked boxes, e.g., in case you want to print the list and check the tasks with a pen.

Related

bookdown! Undefined control sequence. <recently read> \passthrough

I find that when use pandoc --listings, to render code chunk with latex listings package, it will change character, as github says, it is a bug. So pandoc had introduced \passthrough to process it.
I decide to update my pandoc to 2.2.1 version, the newest current. But it pops error like this,
! Undefined control sequence.
<recently read> \passthrough
I thought it may be because of listings package too old without \passthrough. so I update to texlive 2018. it still had this problem. I submit this problem in https://github.com/rstudio/bookdown/issues/591
I had searched some result as,
https://github.com/laboon/ebook/issues/139
https://github.com/rstudio/bookdown/issues/591
but none can solve. Any suggestion? Thank you.
I think I should add this command by myself. texupdate too slow.
This issue is not relevant to your LaTeX distribution, so there is no need to reinstall or update LaTeX.
Pandoc 2.x puts verbatim text in \passthrough{} defined at
https://github.com/jgm/pandoc-templates/blob/052428151/default.latex#L169
if the --listings flag is used in the command line.
$ echo '`text`' | pandoc -f markdown -t latex --listings
\passthrough{\lstinline!text!}
A few possible solutions (from the easiest to hardest):
Set the option template to null in bookdown::pdf_book, i.e.,
bookdown::pdf_book:
template: null
This means using Pandoc's built-in Pandoc template, which has defined \passthrough.
Install the development version of rmarkdown: devtools::install_github('rstudio/rmarkdown'), in which I have added the command.
Define the command \passthrough in a custom Pandoc LaTeX template (https://bookdown.org/yihui/bookdown/templates.html), and use the custom template via the template option of bookdown::pdf_book().

Jupyter Notebook save to PDF without Code

This has been an ongoing issue for me, as I would love to use Jupyter Notebook to write my research reports, but have found it very difficult to export my Jupyter Notebooks to PDF without code and without large formatting errors.
I am able to download the notebooks as PDF, but have not found a way to hide the code, or have the PDF resemble the formatting of the notebook.
No solution I've found on SO has been sufficient for my issue, so it may be possible that this is not the intended functionality of Jupyter Notebook.
Have you tried this:
jupyter nbconvert path/to/your/ipynb --to=pdf --TemplateExporter.exclude_input=True
For more on the flags, you can refer to nbconvert config options
I have successfully converted .ipynb to .html exclude the code blocks
I followed the suggestion by 0xffff above but the PDF output did not behave as intended (code blocks were still included).
However, their suggestion inspired me to try converting to html first using the following call:
jupyter nbconvert path/to/your/ipynb --to=html --TemplateExporter.exclude_input=True
This behaved as intended, and from there, it was straightforward to print the output to PDF in a browser.
Regarding the issue with the --to=pdf flag, I've opened up an issue on the Jupyter Notebook git repo: https://github.com/jupyter/notebook/issues/3804. Will report back once I get a response.
nbconvert
nbconvert is an official package, and other answers have mentioned it. However, they did not mention there are two ways to convert to PDF.
The default option uses LaTeX, and it's often a pain to install:
jupyter nbconvert notebook.ipynb --to=pdf
A newer option is to use the webpdf converter, this does not require LaTeX
jupyter nbconvert notebook.ipynb --to=webpdf
Quarto
Quarto is the newest option. The defaults are prettier than nbconvert, and it has advanced features to customize the output PDF. However, it uses pandoc (and pandoc uses LaTeX), so you must install both first.
quarto render notebook.ipynb --to pdf
Quarto is a new project, and I often run into problems (I couldn't convert the sample notebook); however, the project is in active development and I'm sure it will get better.
Online converters
The last option is to use one of the many online services. The two main caveats are 1) You might not want to upload your notebooks to some random website, and 2) It's often unclear what engine they use to convert the notebooks. I've tried many of them with mostly negative results.
I created one online converter that uses nbconvert and deletes your notebook as soon as it's converted.
If you manually create the PDF, there is a simpler solution: add the following code block & execute it
from IPython.core.display import HTML
HTML('<style>.input, .jp-InputArea {display: none !important}</style>')
Code will disappear both in the "normal" UI and in print preview / export to HTML. Open print preview, generate the PDF - it looks great now, clear the output of this one cell to bring the code back, done

Change default skeletons for RStudio

RStudio has a wonderful set of skeletons for packages and Rmd documents. But, I'd like to know if it's possible to change the defaults to a "skeleton" of your own design. If, like me, you package your research for yourself/clients, you quickly find yourself deleting and copying the same work over and over.
I suppose there are two related questions here:
Can you change the default package skeleton?
Can you change the default Rmd skeleton?
There is no supported way to do this. However, the skeletons are stored as ordinary files in your filesystem, so there's nothing stopping you from modifying them. For instance, if you're on the Mac, this file provides the default Rmd skeleton:
/Applications/RStudio.app/Contents/Resources/resources/templates/r_markdown_v2.Rmd
On Windows, it's here:
C:\Program Files\RStudio\resources\templates\r_markdown_v2.Rmd
I didn't realize it then, but I was actually looking for a custom format. The details of which are documented extensively on the rmarkdown rstudio site.
http://rmarkdown.rstudio.com/developer_custom_formats.html

Multimarkdown in GitHub's Atom editor - made a start, want to make more progress

To extend the basic Markdown support in Atom, I've converted the TextMate Multimarkdown bundle (unescaping one hash sign - see the process on this Atom discussion). The (converted) TextMate bundle files are now in my Atom config folder.
Markdown syntax now highlights okay (and differently from the built-in GitHub Markdown) when I choose 'Multimarkdown' from the syntax list. The table sytnax appears to pick out table heads, but there's no preview and no support for definition lists.
Can someone point me to the file(s) in Atom I'd need to work on to get:
a preview pane?
syntax highlighting for definition lists?

Sweave syntax highlighting in output

Has anyone managed to get color syntax-highlighting working in the output of Sweave documents? I've been able to customize the output style by adding boxes, etc. in the Sweave.sty file as follows:
\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontseries=bc,frame=single}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{frame=leftline}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontseries=bc}
And I can get the minted package to do syntax highlighting of verbatim-code blocks in my document like so:
\begin{minted}{perl}
use Foo::Bar;
...
\end{minted}
but I'm not sure how to combine the two for R input sections. I tried the following:
\DefineVerbatimEnvironment{Sinput}{minted}{r}
\DefineVerbatimEnvironment{Scode}{minted}{r}
Any suggestions?
Yes, look at some of the vignettes for Rcpp as for example (to pick just one) the Rcpp-FAQ pdf.
We use the highlight by Romain which itself can farm out to the hightlight binary by Andre Simon. It makes everything a little more involved---Makefiles for the vignettes etc pp---but we get colourful output from R and C/C++ code. Which makes it worth it.
I have a solution that has worked for me, I have not tried it on any other systems though so things may not work out of the box for you. I've posted some code at https://gist.github.com/797478 that is a set of modified Rweave driver functions that make use of minted blocks instead of verbatim blocks.
To use this driver just specify it when calling the Sweave function with the driver=RweaveLatexMinted() option.
Here's how I've ended up solving it, starting from #daroczig's suggestion.
\usepackage{minted}
\renewenvironment{Sinput}{\minted[frame=single]{r}}{\endminted}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{frame=leftline}
\DefineVerbatimEnvironment{Scode}{Verbatim}{}
While I was at it, I needed to get caching working because I'm using large data sets and one chunk was taking around 3 minutes to complete. So I wrote this zsh shell function to process an .Rnw file with caching:
function sweaveCache() {
Rscript -e "library(cacheSweave); setCacheDir(getwd()); Sweave('$1.Rnw', driver = cacheSweaveDriver)" &&
pdflatex --shell-escape $1.tex &&
open $1.pdf
}
Now I just do sweaveCache myFile and I get the result opened in Preview (on OS X).
This topic on tex.StackExchange might be interesting for you, as it suggest loading the SweaveListingUtils package in R for easy solution.

Resources