# Tag Info

92

I think this is the easiest option! --- title: "Title" author: "Me" header-includes: - \usepackage{bbm} output: pdf_document --- (Edited to have three, instead of four, hyphens to open and close the YAML front-matter)

54

Here's Pandoc-based solution. You will have to enable --shell-escape for this to work, since it uses \write18. Depending on what you want, you may need to customize the Pandoc options. \documentclass{article} \usepackage{fancyvrb} \newenvironment{markdown}% {\VerbatimEnvironment\begin{VerbatimOut}{tmp.markdown}}% {\end{VerbatimOut}% \...

37

(See Update at the end, to get proper colors) By default pandoc uses its own highlighting engine, but it can be changed to use package listings instead. Simply add --listings option to your pandoc command line. However, the format used by listings does not break long lines either, but you can prepare all the required options in a separate tex file, for ...

36

A proper markdown parser is a task too complex for latex. Not because TeX is not a Turing complete language (it is), but because it would be very difficult to implement, and probably will have a very poor performance. One idea which immediately comes to mind is to use LuaTeX, and code the markdown parser in Lua language. This sound certainly feasible. ...

35

I'm not sure why a Pandoc-based solution/answer on this page harvested so many upvotes, while being overly complicated. If you use Pandoc, the method is far easier: Just write Markdown. At occasions where you want to apply LaTeX features in your final document, just sprinkle the Markdown with your LaTeX snippets... Here is a working (not so minimal) ...

35

As per this page on the R Markdown website, you can add whatever you want to the preamble via the in-header option in the YAML header; e.g., ---- title: "Titre" date: Fecha output: pdf_document: includes: in_header: mystyles.sty ---- In mystyles.sty, located in the same directory as the .Rmd, you could have a whole list of ...

31

The nice thing here is that you can turn the feature on with \starON and turn it off with \starOFF (the default condition). Here is the MWE. \documentclass{article} \makeatletter \def\starparse{\@ifnextchar*{\bfstarx}{\itstar}} \def\bfstarx#1{\@ifnextchar*{\bfitstar\@gobble}{\bfstar}} \makeatother \def\itstar#1*{\textit{#1}\starON} \def\bfstar#1**{\textbf{#...

27

Try adding fig_caption: yes to the YAML header of your .Rmd file. It will look something like this: --- title: "Untitled" author: "Nicholas" date: "20/09/2014" output: pdf_document: fig_caption: yes --- There's more information here: http://rmarkdown.rstudio.com/pdf_document_format.html

25

So if I understood your question correctly, you want to do something like GitHub's markdown style. So I created some commands and environments to supply a GitHub-like style based on Adam Pritchard's Markdown Cheatsheet. I used Source Sans Pro and Source Code Pro fonts, so you'll have to download and install them on your operating system. Here are the direct ...

25

This is possible with pandoc. If the Markdown you've posted is in the file test.md you can generate a PDF called test.pdf with the following command: pandoc test.md -o test.pdf The PDF file looks like this: pandoc converts the Markdown to a PDF using LaTeX. It recognizes that the input is Markdown from the file extension, but if you use a different file ...

24

Proof of concept The following code implements a "proof of concept" showing that the approach (1) I proposed in another answer is feasible. This example defines a Markdown environment which dumps its contents verbatim to an auxiliar file (called \jobname-aux.md), and inmediatelly uses Lua to parse that file as markdown. For this parsing it uses the library ...

24

Beside writing a custom template, you can add code to the header using --include-in-header=FILENAME: % filename: fontoptions.tex \setmainfont[ BoldFont = Font-Bold.otf, ItalicFont = Font-Italic.otf, BoldItalicFont = Font-BoldItalic.otf ]{Font-Regular.otf} and call: $pandoc --pdf-engine=xelatex --include-in-header=fontoptions.tex input.md -o output.pdf ... 23 You can pass the lang option to the template using -V which passes it further to the babel package. pandoc -V lang=dutch somefile.markdown This is translated to the following LaTeX code which should result in dutch chapter headings. \usepackage[dutch]{babel} 20 Any markdown flavor is indeed a better option than LaTeX to focus on contents and format a document easily with a decent format, no doubt. But the paradise vanishes when you need more than standards sections and bulleted list. Simple formatting options such as centering an image or making two columns are not available. This is not a criticism of markdown:... 17 \documentclass{report} \setcounter{secnumdepth}{5} \begin{document} \part{Part} \chapter{Chapter} \section{Section} \subsection{Subsection} \subsubsection{Subsubsection} \paragraph{Paragraph} \subparagraph{Subparagraph} \end{document} You can change the formatting of these using the titlesec package. 17 pandoc cannot convert a .bib file into another file format1. However, it can convert a .tex file which contains references (called from a .bib file) into a pdf, odt, html, ... If your .tex file just contains the \nocite{*} command, the result is similar (you will have all your references printed). Here is the magic command: pandoc test.tex -o output.odt --... 16 For ConTeXt, I have written a module, t-filter, that provides a nice user-interface for running external programs on a file. Using that module, you can write: \usemodule[filter] \defineexternalfilter [markdown] [filter={pandoc -t context -o \externalfilteroutputfile}] after which you can use \processmarkdownfile{....} to convert a markdown file ... 16 If you want to use citations, you also have to define the CSL-style (Citation Style Language) to be used, via a *.csl-file you have to reference. Here is an MWE in Markdown. It tests a few different methods to provide references to citations in Markdown: # Markdown source code for relevant part of this page ` {.markdown} i. [@nonexistent] i. @... 16 Pandoc is what you need. This tool helps you convert any markup format to another one including from latex to markdown. For your need, first you need to install pandoc into your system (available for all MacOS, Windows, Linux) and then use this command line pandoc -s example4.tex -o example5.text You can also convert your texts online by using a tool ... 15 A simple solution is to add a line with a backslash and space immediately after the figure, followed by a blank line: ![Alt text](image.png) \ Some text after the figure... Do not forget the space after the backslash! This seems to work on Pandoc 1.12.4.2. Edit: as pointed out in the comments, this will suppress figure captions. 14 You may wanna try kramdown, which has the ability to convert your markdown files to LaTeX source file: kramdown -o latex --template document some.markdown >some.tex 13 This is most likely because the figure environment floats, which is not what you're after. For this you have a couple of options: Add the float package which provides the H float specifier, allowing you to use \usepackage{float}% http://ctan.org/pkg/float %... \begin{figure}[H] %... \caption[<ToC>]{<regular>} \end{figure} stopping the float ... 13 As of pandoc-citeproc-0.4 pandoc-citeproc has support for a \nocite{*}-equivalent. mybib.bib file: @article{behbahani2014aircraft, title={Aircraft Integration Challenges and Opportunities for Distributed Intelligent Control, Power, Thermal Management, Diagnostic and Prognostic Systems}, author={Behbahani, Alireza R and Von Moll, Alexander and ... 12 There are two levels below \subsubsection which are \paragraph and \subparagraph. Whether some sectioning command is numbered or appears in the table of contents is selected by the secnumdepth and tocdepth counters, respectively. 11 The following solution uses LuaLaTeX's capabilities to define a function, called allstars, which converts instances of pairs of groups of asterisks -- ***...***, **...**, and *...* -- into "traditional" LaTeX code: {\bfseries\itshape ...}, {\bfseries ...}, and {\itshape ...}, respectively. The code assumes that asterisk-based markdown does not span ... 11 Pandoc has you covered! It is set up to produce document "fragments" by default, but there's the -s or --standalone flag, which will give you a whole .tex file. So something like pandoc -s -t beamer SLIDES -o example8.tex should do the trick. 11 The following command may surprise you, because it achieves in a single pipeline what you want (or at least, it achieves what I think that you want). The command fits into a single Tweet even :) : pandoc test_dummy.tex -f markdown -t html | grep -E '(^<|^$|^ *$)' \ | grep -v "^<p" | pandoc -f html -o tables.pdf Or, to format it a bit ... 10 Probably, newer versions of pandoc fix this problem. I've just run my simple example: # Section ## Subsection ### Subsubsection #### Paragraph ##### Subparagraph ###### Level 6 through Try Pandoc online!, and the output does use \paragraph: \section{Section} \subsection{Subsection} \subsubsection{Subsubsection} \paragraph{Paragraph} \subparagraph{... 10 With \lstdefinestyle you can define as many styles as you wish; then you can use \lstnewenvironment to define new listing environments using those new styles; in this way you can easily change the styles for your listings as required. You can still use \lstset to set general settings (applicable to all the listings). A simple example: \documentclass[]{... 10 You can change the default.latex template in order to allow horizontal and vertical scaling. Get the template: pandoc -D latex > mytemplate.latex Find the section$if(graphics)$. . .$endif\$ and replace its content with: \usepackage{graphicx} % Redefine \includegraphics so that, unless explicit options are % given, the image width will not exceed ...

Only top voted, non community-wiki answers of a minimum length are eligible