I am using doxygen 1.9.1 to make some documentation.
I am using markdown pages for that.
I would like to know if it is possible to auto number the figures and tables.
Additionally, I would to know how to cross-references the images during the text.
An example:
\image html image1.svg "Figure 1: Example Image" width=350px
This will put image1.svg in the document with the caption
Figure 1: Example Image
However, I do not know how to cross-reference this in the text since there is no \label
Does doxygen allow a more laTexy way to inputting images:
\begin{figure}
\includegraphics[width=0.6\textwidth]{image1.svg}
\caption{Example Image}
\label{fig:1}
\end{figure}
Related
I have defined the variables and data necessary to generate a frequency table in RMarkdown, to export it to Moodle, using R-exams:
xsubio<-c(sample(5:35,5))
xsubi<-sort(xsubio)
frecuencias<-sample(0:30 ,5)
tabla<-data.frame(xsubi,frecuencias)
colnames(tabla)<-c(" Edades" ,"Personas")
Through chunk I generate the table:
```{r, eval=TRUE,echo=FALSE,results='asis',warning=FALSE,message=FALSE,error=FALSE}
library(exams)
print(xtable(tabla), include.rownames=FALSE)
```
When exporting to PDF, using exams2pdf, the table is displayed perfectly:
But, when exporting to Moodle, using exams2moodle, the table disappears:
What do I have to do to make it appear?
Problem: You have an exercise with formatting in Markdown and use xtable() to insert a table in LaTeX. This mixture of Markdown+LaTeX is no problem when converting the exercise to PDF. Internally, this preserves the LaTeX table and just converts the Markdown parts to LaTeX as well before rendering the LaTeX to PDF. However, the same is not possible automatically when converting the Markdown exercise to HTML for Moodle. The converter then does not separate the LaTeX part automatically to convert it to HTML.
In short: The different markups must be sufficiently in sync. Markdown+LaTeX markup for PDF output works and Markdown+HTML for HTML output works. But what would be even better is to have the markup fully in sync, i.e., LaTeX+LaTeX or Markdown+Markdown. Such exercises can then be rendered to either PDF or HTML automatically.
Possible solutions:
Markdown+Markdown: Markdown table markup in R/Markdown (Rmd) exercise
I would recommend that you simply produce tables in Markdown via knitr::kable() rather than xtable::xtable(). Thus, the code chunk for the table simply becomes
knitr::kable(tabla, format = "markdown")
and then the tables are rendered correctly in both PDF and HTML-based formats like Moodle.
LaTeX+LaTeX: LaTeX table markup in R/LaTeX (Rnw) exercise
In case you prefer to keep on generating LaTeX tables with xtable() another route would be to change the markup of the R/exams exercise to Rnw (R/LaTeX). See the First steps tutorial on the R/exams web page for how to do that.
Markdown+Adaptive: Choose the right table markup depending on the output format
Using the match_exams_call() function you can determine in a running exercise which exams2xyz() interface is being used to process it. So you could do
type <- if(match_exams_call() %in% c("exams2pdf", "exams2nops")) "latex" else "html"
print(xtable(tabla), type = type, ...)
Then either LaTeX or HTML format is produced by xtable().
All three solutions work in principle but I think Solution 1 (kable()) is the best and most robust in your case.
Bonus remark: If you are using R/exams >= 2.4-0 you can use exams2moodle(...,table = TRUE) to get nicer table formatting in Moodle.
I use the following code snippet (with type = "latex"), when I require a PDF output:
```{r, eval=TRUE, only.contents=TRUE, echo=FALSE, results='asis',
warning=FALSE, message=FALSE, error=FALSE, comment=FALSE}
library(exams)
library(xtable)
print(xtable(tabla), include.rownames=FALSE, type = "latex", comment=F)
```
And, when I require outputs for Moodle, I make use of the following code snippet (with type = "html"):
```{r, eval=TRUE, only.contents=TRUE, echo=FALSE, results='asis',
warning=FALSE, message=FALSE, error=FALSE, comment=FALSE}
library(exams)
library(xtable)
print(xtable(tabla), include.rownames=FALSE, type = "html",
comment=F)
```
Results in PDF:
Results for Moodle:
I use '.md' to generate '(index).html' and '(refman*).rtf' documentation with doxygen 1.8.14.
The mathematical equation in '*.md' gives a correct equation in html output but not in the file 'refman.rtf'. The other theoretical parts like paragraph and other stuff work well between *.md and rtf output.
I guess *.rtf is not recognizing the equation part of the *.md document.
Does the RTF generation through doxygen read the *.md files?
Do I need to change any tag to make *.md work with rtf output?
Not only for markdown but also for "normal" doxygen input formulas do not work.
From the documentation:
Doxygen allows you to put LATEX formulas in the output (this works
only for the HTML and LATEX output, not for the RTF nor for the man
page output).
A workaround workflow, at the moment for non inline formulas, is to do something like:
Create an image with the formula e.g in a dummy doxygen run where one does not use MATHJAX, this will result in an image with a name like: 'form_0.png'.
In the code one has to place an if construct like:
\if rtf_run
\image rtf form_0.png
\else
\f... with the formula
\endif
One now has to run doxygen twice:
once for the output without rtf, i.e. without setting rtf_run in ENABLED_SECTIONS
once for rtf output by setting rtf_run in ENABLED_SECTIONS
EDIT June 5, 2018: I've just pushed a proposed patch to github pull request 756. Here the formulas are rendered as png images and included in the RTF documentation.
EDIT: 2018/06/10: The push request has been integrated in the master version on github.
I'd like to add some UML diagrams to my *.dox document, with these requirements:
I'd like to include plain PlantUML document, without doxygen tags in it.
I want it as link to image in my final document, instead of having it on the main page directly.
How can I achieve this goal?
To achieve first requirement try using Plantuml preprocessing. Like this:
/**
* #startuml
* !include my_diagram.txt!0
* #enduml
*/
Second requirement, as I know, is not supported by Doxygen so far.
I believe this is currently not possible, there is no command similar to #dotfile, #mscfile or #diafile which does this for dot, msc or dia source files. But if you want to reuse the same diagram in different pages of the documentation you can let doxygen generate a png file from the code and just include the png file:
\startuml [{file}] ["caption"] [<sizeindication>=<size>]
e.g.:
#startuml{myimage.png} "Image Caption" width=5cm
I did not try this, but this way you might workaround this, you could create an extra page in a .h, .dox or .txt file containing a doxygen comment, where you put all your diagrams in. From this file doxygen generates the png files. Those png files you might embed using the #image command.
I am making a documentation using Doxygen, and using the HTML output only.
I would like to include figures, if possible, with captions and wrapped.
As I understood, I can use HTML-only parts in the source. My attempt is
\image html test.png "A test figure"
#htmlonly
<IMG SRC=”test.png” ALIGN=”left” HSPACE=”50” VSPACE=”50”/>
#endhtmlonly
The result is that the \image generated picture appears, but only the spacekeeper for the generated version. Do I wrong something? How can I insert a captioned figure, wrapped with text?
I am playing with Tal's intro to producing word tables with as little overhead as possible in real world situations. (Please see for reproducible examples there - Thanks, Tal!) In real application, tables are to wide to print them on a portrait-oriented page, but you might not want to split them.
Sorry if I have overlooked this in the pandoc or pander documentation, but how do I control page orientation (portrait/landscape) when writing from R to a Word .docx file?
I maybe should add tat I started using knitr+markdown, and I am not yet familiar with LaTex syntax. But I'm trying to pick up as much as possible while getting my stuff done.
I am pretty sure the docx writer has no section breaks implemented, also as far as I understand --reference-docx allows for customizing styles and not the page layout (but I might also be wrong here), this is from pandocs guide on --reference-docx:
--reference-docx=FILE
Use the specified file as a style reference in producing a docx file.
For best results, the reference docx should be a modified version of a
docx file produced using pandoc. The contents of the reference docx
are ignored, but its stylesheets are used in the new docx. If no
reference docx is specified on the command line, pandoc will look for
a file reference.docx in the user data directory (see --data-dir). If
this is not found either, sensible defaults will be used. The
following styles are used by pandoc: [paragraph] Normal, Title,
Authors, Date, Heading 1, Heading 2, Heading 3, Heading 4, Heading 5,
Block Quote, Definition Term, Definition, Body Text, Table Caption,
Image Caption; [character] Default Paragraph Font, Body Text Char,
Verbatim Char, Footnote Ref, Link.
Which are styles that are saved in the /word/styles.xml component of the docx document.
The page layout on the other hand is saved in the /word/document.xml component in the <w:sectPr> tag, but pandoc's docx writer ignores this part as far as I can tell.
The docx writer builds by default a continuous document, with elements such as headers, paragraphs, simple tables and so on ... much like a html output.
Option #1 (doesn't solve the page orientation problem):
The only page layout option that you can define through styles is the pageBreakBefore which will add a page break before a certain style
Option #2 (seems elegant but hasn't been tested):
Recently the custom writer has been added that allows for a custom lua script, where you should be able to define how certain Pandoc blocks will be written into the output file ... meaning you could potentially define section breaks and page layout for a specific block inserting the sectPr tag into the document. I haven't tried this out but it would be worth investigating. On pandoc github you can check out a sample lua script file for custom html output.
However, this means, you have to have lua installed, learn the language, and it is up to you if you think its worth the time investment.
Optin #3 (a couple of clicks in Word might just do):
As you will probably spend quite some time setting up how to insert sections and what would be the right size, margins, and figuring how to fit the table to such a layout ... I recommend that you use pandoc to put write your document.docx, that you open in Word, and do the layout by hand:
select the table you want on the landscape page
go to Layout > Margins
> select Apply to: Selected text
> choose Page Setup > select Landscape
Now a new section with a landscape orientation should surround your table.
What you would anyway also probably want to do is styling the table and table caption a little (font-size,...), to achieve the best result (all text styling can be already applied with pandoc where --reference-docx comes handy).
Option #4 (in situation when you can just use pdf instead of docx):
As far as I could figure out is that with pandoc does a good job with tables in md -> docx (alignment, style, ... ), in tex -> docx it had some trouble sometimes. However if your option allows for a pdf output latex will be your greatest friend. For example your problem is solved as easily as just using
\usepackage{pdflscape}
and adding this around your table
\begin{landscape}
...
\end{landscape}
This are the options that I could think of so far.
I would always recommend using the pdf format for reports, as you can style it to your liking with latex and the layout will stay the way you want it to be.
However, I also know that for various reasons word documents are still the main way of reviewing manuscripts in many fields ... so i would most likely just go with my suggested option 3, mostly cause it is a lazy and quick solution and because I usually don't have many documents with tons of giant tables with awkward placement and styling.
Good luck ;-)
Based on Taleb's answer here and some officer package functions, I created a little gist that one can use like this:
---
title: "Example"
author: "Dan Chaltiel"
output:
word_document:
pandoc_args:
'--lua-filter=page-break.lua'
---
I'm in portrait
\endLandscape
I'm in landscape
\endPortrait
I'm in portrait again
With page-breaks.lua being the file hosted here: https://gist.github.com/DanChaltiel/e7505e62341093cfdc489265963b6c8f
This is far from perfect (for instance it won't work without the last portrait section), but it is quite useful sometimes.