Resources:
sudo apt-get install pandoc
\documentclass[11pt, a4paper]{book}
\usepackage[
urlcolor = blue,
colorlinks = true,
linkcolor = black
]{hyperref}
\usepackage{graphicx}
\usepackage[
font=small,
format=plain,
labelfont=bf,up,
textfont=it,up]{caption}
\usepackage{fullpage}
\usepackage{xeCJK}
\setCJKmainfont{AR PL UMing CN}
\begin{document}
\title{Linux Guide for Chinese Beginners}
\author{Peter Wang}
\date{2001.1.1}
\maketitle
\tableofcontents\newpage\thispagestyle{empty}
\end{document}
#!/bin/bash
cd book-content/
pandoc ch01.md -o ch01.tex
sed -e '/tableofcontents/r ch01.tex' ../latex/template.tex >book.tex
xelatex book.tex
mv book.pdf ..
rm book.* *.tex &>/dev/null
...
sed -i 's/^\\section{/\\chapter{/g' book.tex
sed -i 's/^\\subsection{/\\section{/g' book.tex
sed -i 's/^\\subsubsection{/\\subsection{/g' book.tex
...
...
sed -i 's/\\begin{verbatim}/{\\footnotesize \\begin{quote}\\begin{verbatim}/g' book.tex
sed -i 's/\\end{verbatim}/\\end{verbatim}\\end{quote}}/g' book.tex
...
#!bin/bash
cd book-content/
>all.tex
for file in `ls *.md`
do
echo $file
shortname=${file%.*}
pandoc $file -o $shortname.tex
cat $shortname.tex >> all.tex
rm $shortname.tex
rm *.log 2>/dev/null
done
sed -e '/tableofcontents/r all.tex' ../latex/template.tex >book.tex
sed -i 's/^\\section{/\\chapter{/g' book.tex
sed -i 's/^\\subsection{/\\section{/g' book.tex
sed -i 's/^\\subsubsection{/\\subsection{/g' book.tex
sed -i 's/\\begin{verbatim}/{\\footnotesize \\begin{quote}\\begin{verbatim}/g' book.tex
sed -i 's/\\end{verbatim}/\\end{verbatim}\\end{quote}}/g' book.tex
xelatex book.tex
xelatex book.tex
mv book.pdf ..
rm book.* *.tex &>/dev/null