Markdown equivalent to LaTeX chapters and parts? - latex

I am thinking about the relationships between markdown and LaTeX, on of (among many) of the differences between the two is sectioning. Markdown uses hashtags as equivalents to HTML header tags, similarly LaTeX has \section{}, \subsection{}, etc. for sectioning. However, LaTeX also has \chapter{} and \part{}, but I can't think about what these would equate to in Markdown. Ideas?
One thought is to turn separate parts and chapters into separate Markdown documents, but that doesn't really feel right.

One of Markdown's design goals is to be very simple:
Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags.
Since LaTeX is more expressive than HTML, Markdown syntax corresponds to an even smaller subset of LaTeX than of HTML.
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.
If you are targeting HTML, you should be looking for HTML that corresponds to a chapter or a part. One option is the <article> tag:
The <article> HTML element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable (e.g., in syndication). Examples include: a forum post, a magazine or newspaper article, or a blog entry, a product card, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
Another option is <section>:
The <section> HTML element represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it. Sections should always have a heading, with very few exceptions.
If you are targeting LaTeX (or PDF via LaTeX) you'd want to similarly use LaTeX directly. Exactly how you do that depends on the tool you are using. Pandoc, for example, supports raw LaTeX via the raw_tex extension.

Related

Tables in R-markdown not shown in Moodle - exams2moodle

I have a serious problem with rendering tables in Moodle once I upload the Moodle XML file generated by R-exams package to Moodle. I am using exercise files in .Rmd format handed to me from a previous professor's assistant. These .Rmd files contain lots of tables using Latex language. Once I upload the Moodle XML file, all of these tables are simply missing. I have tried to look up a solution, but could not find anything helpful on this.
Interestingly, these tables are rendered properly into PDF when using "exams2pdf" command in R-studio. However, when using "exams2moodle", these tables are simply not shown in Moodle.
I am showing an example of the table in one of these .Rmd files below:
I would appreciate if anyone could provide any guidance, as I got really stuck with this issue.
TL;DR: The problem is that you mix an exercise in Markdown format with LaTeX content. This only works if the rendering goes via LaTeX (see below for details). Instead you could convert your question from R/Markdown (.Rmd) to R/LaTeX (.Rnw) - or convert the formatting of the table from LaTeX to Markdown. Both would be feasible in this case. If you need help with this, please share (a link to) the code for the exercise and not just a screenshot of parts of it.
Hint: If you're using at least version 2.4-0 of exams, exams2moodle() gained an argument table where you can set a class for formatting the table a bit more nicely, e.g., table = "table_shade" or "table_rule" or "table_grid".
Details: You have a question in R/Markdown format which contains a table in LaTeX format. When you use exams2pdf() this works because rendering works in the following steps:
knit R/Markdown to Markdown (preserving the LaTeX table).
Convert Markdown to LaTeX via pandoc (preserving the LaTeX table).
Render LaTeX (including the table) to PDF using texi2pdf or latexmk.
Thus, it is crucial that you do a rendering step from LaTeX to the output format. This is not the case though for exams2moodle() or other engines based on HTML output. The steps are just:
knit R/Markdown to Markdown (preserving the LaTeX table).
Convert Markdown to HTML via pandoc (which does not know how to render the LaTeX table and hence drops it).
Embed HTML in XML for Moodle.
Thus, the problem is that there is no rendering or transformation step from LaTeX in this case. The same would be true if you had R/Markdown exercises with HTML content. These could be rendered with exams2moodle() because the HTML would just need to be preserved - but not with exams2pdf() because the HTML would not be converted to LaTeX.

Typing LateX expression in MathJax without displaying as a Math expression

On an online tutorial page using MathJax, how would we teach students: Type \[x^2+1\] to display
There are actually several similar questions but a thorough answer might be a good reference point for SO.
Ther are two ways of handling this.
Escape a particular expression
This is quick and easy and can be done by authors themselves.
As per the documentation, the TeX pre-processors stops parsing at HTML tags. So wrapping the delimiters in some markup will prevent it from rendering
E.g.,<span>\[</span>x^2+1<span>\]</span>
Skip larger blocks
As per the documentation, the TeX pre-processor has two configuration options to skip parts of the content:
skipTags (skip by tag name), default: script,noscript,style,textarea,pre,code
ignoreClass (skip by class name), default: tex2jax_ignore
E.g., <pre>\[ x^2 + 1 \] </pre>

R --markdown to latex - tables do not show up

I am using Knitr in Rstudio, to generate markdown files. I display the tables via xtable package and it shows up nicely in html file. However, when I converd .md to latex via pandoc - the latex file does not contain the tables as it is supposed to be, but only the values in table without any command.
Markdown - Knitr input
In order to give a better idea, the following table provides a sample of
data rows:
```{r table, results='asis', echo=FALSE}
r = read.table("C:/aR_files/data.txt",sep=",", header=TRUE,as.is=TRUE)
r$X = NULL;
print(xtable(r), type='html')
```
Latex
In order to give a better idea, the following table provides a sample of
data rows:
Row1
Row2
Val1
Val1
I thought I may be missing a latex package, so I downloaded ctable.sty, but still I get the same output. Any ideas appreciated, thanks!
I use a very similar workflow to yours and your best bet is to abandon the often clunky xtable package and use the pander package to print your tables. You can wrap any object that you might want to display as a table in the generic pander() function. This is a wrapper for the pandoc.table() function which has several options. If you specify the option style = "XXX" you can achieve what you are asking about here. There are 4 different styles you can choose from; "multiline" (the default), "grid", "simple", or "rmarkdown". I frequently knit rmarkdown documents from within Rstudio and then convert them to Word documents using the pander package:
library(pander)
Pandoc.convert("C:/Users/BlahBlahBlah/Document.md", format="docx")
All of the 4 table styles get turned into table objects upon conversion to .docx format, but only one table style looks right in the .docx document and the .html file that results from the initial "knit". That style is "rmarkdown". You can implement this 2 ways. One would be:
```{r table, results='asis'}
pandoc.table(myTable, style = "rmarkdown")
```
I prefer to set the table style globally at the beginning of my document however, ensuring that all my tables have the same formatting and also allowing me to use the more succinct pander(x) instead of the more verbose pandoc.table(x, style = "someStyle"):
```{r table, results='asis'}
panderOptions("table.style", "rmarkdown")
pander(myTable)
```
There are some side effects of using the rmarkdown style however. Mainly, it does not support newline characters within cells, so buyer beware. I experimented with the different styles and eventually decided that I liked the default style of "multiline" because of it's flexibility with line breaks within cells, even though the .html files I generate look silly. This doesn't bother me though, as I really only use the .docx files that I convert from the .md files. I wrote a blog post about making nice tables that you might find useful. It weighs the pros and cons of several methods including xtable() and several pander() scenarios.

How do i append a paper in appendix in latex?

In my Master thesis i want to append a paper as an appendix to the thesis. I am writing in LateX in the "report" style. At the end of the thesis there are some code in Appendix A, and in Appendix B i want to add a paper, written in latex. How do i append the paper at the end, as a standalone paper, with its own bibliography etc?
And the cleaner option consists of using pdfpages. That way rebuilding your document doesn't require appending it again :). The other options aren't really necessary in your case I believe: they mainly concern selecting specific pages and changing the page layout to multiple pages per sheet.
Note very clean, but you could just compile the two files as PDF and the concatenate the them.

Lighweight markup (wiki) language for documenting

When I write papers or documentation it makes think using LaTeX or OpenOffice is overkill as I usually only need some markup elements (bold, headlines, lists, ...) . I'd like to write my documents using a wiki style markup as this is very efficient.
For example:
= Introduction =
'''HTML''' is a markup language...
In the end I'd like to simply convert it to PDF. (Cross-platform was nice too.)
compiler.exe -pdf input.wiki output.pdf
Is there a tool (or simple tool chain) to do this job?
I'd personally like to not make use of LaTeX as a transformation step. There are tools doing this job transforming lightweight syntax to TeX and then to PDF/PS.
You might find that MarkDown gets pretty close to what you want.
MarkDown is a simple technique for marking up text files so that they can be post-processed into other forms. One of the nice things about MarkDown is their goal that a marked-up document should be simply readable as a straight text file:
The overriding design goal for
Markdown’s formatting syntax is to
make it as readable as possible. The
idea is that a Markdown-formatted
document should be publishable as-is,
as plain text, without looking like
it’s been marked up with tags or
formatting instructions.
PanDoc looks like it might be good companian tool to convert the MarkDown straight into PDF files. There may well be other choices - PanDoc is just the best tool I found with a quick Google search.
reStructuredText.
You can use Sphinx to generate HTML and LaTeX (and later PDF with pdflatex).
There is also rst2pdf, don't know if it's mature.
You could use Markdown (example) and then use Pandoc (which also works with reStructuredText and several other wiki-like syntaxes) to convert to PDF.

Resources