Skip to content

Instantly share code, notes, and snippets.

@jdhao
Last active December 28, 2021 02:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdhao/90fcc239cfa3bba77e10185580e16170 to your computer and use it in GitHub Desktop.
Save jdhao/90fcc239cfa3bba77e10185580e16170 to your computer and use it in GitHub Desktop.
This is a Sublime Text build system which converts Markdown file to PDF using Pandoc and supports both English and Chinese. Features are: numbered section; url color; highlighted inline code and code blocks; build and preview using Sumatra pdf reader
\usepackage{fancyvrb,newverbs}
% set up page geometry
\usepackage[top=2cm, bottom=1.5cm, left=2cm, right=2cm]{geometry}
% change background color for inline code in
% markdown files. The following code does not work well for
% long text as the text will exceed the page boundary
\definecolor{bgcolor}{HTML}{DADADA}
\let\oldtexttt\texttt
\renewcommand{\texttt}[1]{
\colorbox{bgcolor}{\oldtexttt{#1}}
}
%% color and other settings for the hyperref package
\hypersetup{
bookmarksopen=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=NavyBlue,
}
{
"shell_cmd": "pandoc -f markdown-raw_tex --pdf-engine=xelatex -N --highlight-style=espresso -H \"${packages}\"/User/head.tex -V CJKmainfont=\"Noto Sans CJK SC\" -V colorlinks \"${file}\" -o \"${file_path}/${file_base_name}.pdf\" ",
"path": "C:/Users/east/AppData/Local/Pandoc/;%PATH%",
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "text.html.markdown",
"variants":
[
{
"name": "Build and View",
"shell_cmd": "pandoc -f markdown-raw_tex --pdf-engine=xelatex -N --highlight-style=espresso -H \"${packages}\"/User/head.tex -V CJKmainfont=\"Noto Sans CJK SC\" -V colorlinks \"${file}\" -o \"${file_path}/${file_base_name}.pdf\" && SumatraPDF \"${file_path}/${file_base_name}.pdf\" ",
"path": "C:/Users/east/AppData/Local/Pandoc/;%PATH%",
// "shell_cmd": "start \"$file_base_name\" call $file_base_name"
}
]
}
@jdhao
Copy link
Author

jdhao commented Feb 14, 2019

The head.tex file should be put under directory C:\Users\Administrator\AppData\Roaming\Sublime Text 3\Packages\User on Windows system. A more robust way to find the package directory is use sublime.packages_path() command in the Sublime Text console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment