Using quarto in RStudio to generate tufte book with context engine - r-markdown

I have been trying the tufte handbook style on RStudio using the skeleton.Rmd script. It works ok excepting the [#R-base] side citation that sets cursive for the rest of document probably because of bad format in reference. Other than that, it works nicely. As I am not very experienced in TeX output in Rmarkdown, I would like to know if the Tufte format is necessarily linked to LaTeX and xelatex engine, or using the ConText engine can manage it and I could use ConText engine in Quarto to generate Tufte formatted document with Tex output. I'm using Quarto with context engine to write a technical book and that option would be so nice. Thanks for help!

The tufte styles use the tufte LaTeX package; they cannot be used with ConTeXt.
There are very few (if any) predefined styles for ConTeXt, so you'd have to build this yourself. The only help I can offer is to link this ConTeXt template, which might contain a few pointers on how to build a suitable ConTeXt pandoc template.

Related

Use markdown syntax in markdown chunks

I'm using bookdown to write my math notes, bookdown provide an feature that one can use
```{theorem}
{theorem content}
```
to write theorems and auto numbered.
However, my preview tool does not realize i'm still wring markdown and the preview will look like
Is there any way to solve it?
Quoting cderv in the issue you reported on GitHub:
There is a new way to write this environment using custom blocks syntax. It is in NEWS but not yet documented in the book. Will do soon.
You can use
::: {.theorem #label name="name"}
<any markdown syntax content>
:::
It works for HTML and PDF output.
I don't know what "other preview tool" you are referring but the content inside this block will be markdown, so I think it will be better for your usage.
The new RStudio Visual Markdown editor helps a lot to write and see those divs !
https://blog.rstudio.com/2020/09/30/rstudio-v1-4-preview-visual-markdown-editing/

Converting HTML file to PDF using Win32/MFC

As part of my application, my client has requested that I include an automated e-mailing system. As part of this system, I generate HTML code and use automation to send it via. Outlook.
However, they also require a PDF copy of the HTML document to be sent as an attachment. My initial attempts involved using libHaru, which proved difficult to use efficiently, as I was required to create the PDF document from scratch, which required computation of the position of each of the lines in a table, and positioning of all the text, etc.
I was wondering if there would be a way to programmatically convert HTML code (or an HTML file if need be) into a PDF document either by using Win32/MFC itself or an external library.
Thanks in advance!
EDIT: Just to clarify, I am looking for solutions which minimize external dependencies.
You should evaluate this utility wkhtmltopdf:
http://code.google.com/p/wkhtmltopdf/
You can call it from the command line without the need to run a setup.
I use it generating my output documents as html then cal a ShellExecute(...) to convert it to PDF. It's great!
Inside uses webkit + qt. So compability with modern HTML is OK.
Hope it helps.
I'd take a look at PDF Creator, which can be used as a COM object (that acts pretty much like a printer). I haven't used it to print HTML, so I'm not sure, but my guess is that you'll probably end up having to instantiate a web browser control to render the HTML, and then feed it from there to the PDF control.
Some possible answers are in this thread:
C++ Library to Convert HTML to PDF?
Not sure if they will satisfy your particular requirements, but these might at least get you started.
Edit:
Some other possible options here.
Not MFC but you can try QtWebKit. It can render and export HTML to PDF, PNG, JPEG

Drawing control-theory block diagrams with Doxygen

I'm working on a C++ project in the field of automatics I'd like to start documenting. I'm rather decided for Doxygen. But, apart of documenting particular fields of data and drawing class-hierarchy UML-diagrams, I'd like to document several methods' functionalities with block diagrams like this one:
What are the solutions?
I'm familiar with LaTeX. I've read Doxygen has some support for LaTeX, I don't know how far this goes, though. Is it possible to use any LaTeX package within Doxygen? Which particular packages would you recommend and could you provide some simple examples as well?
I'm also open to recommendations of something different than Doxygen.
If it's only about getting the control-systems structure, variables etc. documented you can generate the diagram elsewhere (e.g. Dia, XFig or Inkscape if you want to use open source tools) and embed them into your Doxygen documentation via the image keyword from within your code:
/*!
.. Doxygen doc here..
\image html Data_Model.png "Figure 1: UML Diagram of the Data Source and Data Model Relationships"
*/
To do this you'll need to tell Doxygen in the Doxyfile file where to find the images, and place the images relative to your doxygen path (DOCROOT/images in this case):
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH = images
Using latex extensions or other language driven graphical markups for generating graphs from within Doxygen doc does imho not justify the overhead of learning the language, getting the tool-chain configured and aligned. On the other hand if you have some tool already which is generating the graph automatically (from your code or a config file), it should be a breeze to run the tool from within a Makefile, let it generate the image and embed the image in your doxygen doc via the image keyword.

Is there such a thing like a Printer-Markup-Language

I like to print a document. The content of the document are tables and text with different colors. Does a lightwight printer-file-format exist, which can be used like a template?
PS, PDF, DOC files in my opinion are to heavy to parse. May there exist some XML or YAML file format which supports:
Easy creation (maybe with a WYSIWYG-Editor)
Parsing and manipulation with Library-Support
Easy sending to the printer (maybe with Library-Support)
Or do I have to do it the usual way and paint within a CDC?
I noticed you’re using MFC (so, Windows). In that case the answer is a qualified yes. In recent versions of Windows, Microsoft offers the XPS Document API which lets you create and manipulate a PDF-like document using XML, which can then be printed using the XPS Print API.
(For earlier versions of Windows that don’t support this API, you could try to deal with the XPS file format directly, but that is probably a lot harder than using CDC. Even with the API you will be working at a fairly low level.)
End users can generate XPS documents using the XPS print driver that is available for free from Microsoft (and bundled with certain MS products—they probably already have it on their system).
There is no universal language that is supported across all (or even many) printers. While PCL and PS are the most used, there are also printers which only work with specific printer drivers because they only support a proprietary data format (often pre-rendered on the client).
However, you could use XSL-FO to create documents which can then be rendered to a printer driver using library support.
I think something like TeX or LaTeX (or even troff or groff) may meet your needs. Google them and see.
There are also libraries to render documents for print from HTML source. Look at http://libharu.sourceforge.net/ for example. This outputs a printer-ready .PDF
A think that Post Script is a really good choice for that.
It is actually a very simple language, and it must be very easy to parse becuse it is stack-oriented. Then -- most printers supprort it, and even if you have no support you can use GhostScript to convert for many different formats (Consider GS as a "virtual PS supporting printer").
Finally there are a lot of books and tutorials for the language.
About the parsing -- you can actually define new variables and functions in PS. So, maybe, your problem can be solved (almost) entirely using PS.
HTML + CSS can be printed -- properly. CSS was designed to support this with the media attribute to specify that your CSS is for printer layout, not for screen layout. Tools like PRINCE (free + commercial versions) exist to render this for printing.
I think postscript is the markup language used by printers. I read this somewhere, so correct me if postscript is now outdated.
http://en.wikipedia.org/wiki/PostScript
For more powerful suite you can use Latex. It will give options of creating templates where you can just copy the text.
On a more GUI friendly note, MS-Word and other word processors have templates. The issue is they are not of a common standard or markup.
You can also use HTML to render stuff in a common markup but it will not be very printer friendly.

Help programmatically add text to an existing PDF

I need to write a program that displays a PDF which a third-party supplies. I need to insert text data in to the form before displaying it to the user. I do have the option to convert the PDF in to another format, but it has to look exactly like the original PDF. C++ is the preferred language of choice, but other languages can be investigated (e.g. C#). It need to work on a Windows desktop machine.
What libraries, tools, strategies, or other programming languages do you suggest investigate to accomplish this task? Are there any online examples you could direct me to.
Thank-you in advance.
What about PoDoFo:
The PoDoFo library is a free, portable
C++ library which includes classes to
parse PDF files and modify their
contents into memory. The changes can
be written back to disk easily. The
parser can also be used to extract
information from a PDF file (for
example the parser could be used in a
PDF viewer). Besides parsing PoDoFo
includes also very simple classes to
create your own PDF files. All classes
are documented so it is easy to start
writing your own application using
PoDoFo.
iTextSharp is a free library that you can use in .Net applications. Take a look at the iText page - that is for the iText project, which is a Java library. iTextSharp is part of that project, and is a port to C# and .Net.
Consider Python It have a lot PDF librarys (both creating and extracting) eg:
http://pypi.python.org/pypi/pdfsplit/0.4.2
http://pypi.python.org/pypi/JagPDF/1.4.0
http://pypi.python.org/pypi/pdfminer/20091129
http://pypi.python.org/pypi/podofo/0.0.1
http://pypi.python.org/pypi/pyFPDF/1.52
There are also good tools for using C/C++ code in Python and to create .exe form Python scripts. If you decide to use different language consider Python as prototyping language!