It surprised myself a lot when realized there is no repository for my homework, so here it is.
Some hand in materials will saved here for quick access and unified management.
And below are some tips for using pandoc to convert markdown into HTML or latex.
# gen_slides.sh
# proposal.md is the markdown file we want to convert
pandoc -f markdown -t revealjs --standalone --self-contained proposal.md -o proposal.html -V theme=serif2 -V revealjs-url=H:/class_material/hand_in_homework/pandoc_markdown_revealjs/reveal.js -i
--standalone
generate a standalone HTML file, --self-contained
make all things in it, we use a modified serif
theme (i.e. serif2
), -i
means to display lists incrementally (one item at a time).
As the reveal.js' instruction, append ?print-pdf
at the end of the url and use CHROME to print
it as a pdf file.
\newcommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
print("hello world")
Code generated by pandoc is somewhat like:
\begin{Shaded}
\begin{Highlighting}[]
\BuiltInTok{print}\NormalTok{(}\StringTok{"hello world"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
So, the Shaded
and Highlighting
should take into account. Please see https://blog.jle.im/entry/shake-task-automation-and-scripting-in-haskell.tex
for example. (I also uploaded a backup here)
UPDATE: ABOVE solution can not handle the codes too long and can not be hold in one line, see pandoc-markdown-to-pdf-without-cutting-off-code-block-lines-that-are-too-long for more info.
The author suggestion use pandoc test.md --listings -H listings-setup.tex -o output.pdf
to generate a pretty nice pdf, however, to be used with a latex template, we should not make it generate a standalone latex file, so the command should be something like:
pandoc -f markdown -t latex presentation.md -o latex_file/presentation.tex --listings
Notice that after --listings
we do not specify the listings-setup.tex
file, then we insert all the texts into our template file to use this.
Addition note:
\usepackage{listings} # should be include to use \lstset
linewidth=0.5\textwidth, # to specify the linewidth, useful when in two column template, linewidth=0.5\textwidth
And there is one back up for the listings-setup.tex
file
***
will create a horizontal rule, pretty useful when we are doing a slide presentation, but not so appealing when used for latex. I failed to changed it properly, mostly because just override the \rule
in latex is not acceptable since many latex templates use it too. So it's better to preprocess our files first use a program (I make it easier by just remove all these first).
Change the links into footnotes
\renewcommand{\href}[2]{#2\footnote{\url{#1}}}
Support starred figure environment for two-column figures in latex, the suggestion of make figure with star
, thus figure*
will place figure in the two column template. However, a uniform version of it can be a little hard.
With the suggestion redefine-environment-to-be-a-synonym-for-another we can make all figures into figure*
by define:
\renewenvironment{figure}{\begin{figure*}}{%
\end{figure*}\ignorespacesafterend% as suggested above
}
However, it's not so good when we do want to palace a small image in on column.
According to pandoc-crossref , to make a label for image and set width at the same time, just type:
![caption a](coolfiga.png){#fig:cfa width=30%}
And, to cite it, just use
This will cite \ref{#fig:cfa}
NOTE that without pandoc-crossref
, the markdown file convert to html or tex nicely, it seems that pandoc
itself already has some support to references, but not so much compared with pandoc-crossref
. (In fact, I failed to covert to html or tex with pandoc-crossref
, not so sure why this happened).