Skip to content

Various homework projects in my first year as graduate student.

Notifications You must be signed in to change notification settings

MiaoDX/hand_in_homework

Repository files navigation

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.

Markdown to HTML slides

convert

# 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).

save as pdf

As the reveal.js' instruction, append ?print-pdf at the end of the url and use CHROME to print it as a pdf file.

The markdown to latex part

Remove \tightlist

\newcommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

The code snippet

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

The separation line (horizontal rule)

*** 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).

The links

Change the links into footnotes

\renewcommand{\href}[2]{#2\footnote{\url{#1}}}

Two column figures

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.

Figure reference

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).

About

Various homework projects in my first year as graduate student.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published