template.tex 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. \documentclass[a4paper, 11pt]{article}
  2. \usepackage{geometry} % 設定邊界
  3. \geometry{
  4. top=1in,
  5. inner=1in,
  6. outer=1in,
  7. bottom=1in,
  8. headheight=3ex,
  9. headsep=2ex
  10. }
  11. \usepackage{tabu}
  12. \usepackage[T1]{fontenc}
  13. \usepackage{lmodern}
  14. \usepackage{booktabs}
  15. \usepackage{amssymb,amsmath}
  16. \usepackage{ifxetex,ifluatex}
  17. \usepackage{fixltx2e} % provides \textsubscript
  18. % use upquote if available, for straight quotes in verbatim environments
  19. \usepackage{titling}
  20. \usepackage{lipsum}
  21. \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
  22. \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  23. \usepackage[utf8]{inputenc}
  24. $if(euro)$
  25. \usepackage{eurosym}
  26. $endif$
  27. \else % if luatex or xelatex
  28. \usepackage{fontspec} % 允許設定字體
  29. \usepackage{xeCJK} % 分開設置中英文字型
  30. \setCJKmainfont{STSong} % 設定中文字型
  31. \setmainfont[Mapping=tex-text]{Times New Roman}%\rmfamily 使用的字体,默认英文和数字的字体。 % 設定英文字型
  32. \setromanfont{Georgia} % 字型
  33. \setmonofont{Courier New}
  34. \linespread{1.2}\selectfont % 行距
  35. \XeTeXlinebreaklocale "zh" % 針對中文自動換行
  36. \XeTeXlinebreakskip = 0pt plus 1pt % 字與字之間加入0pt至1pt的間距,確保左右對整齊
  37. \parindent 0em % 段落縮進
  38. \setlength{\parskip}{20pt} % 段落之間的距離
  39. \ifxetex
  40. \usepackage{xltxtra,xunicode}
  41. \fi
  42. \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
  43. \newcommand{\euro}{€}
  44. $if(mainfont)$
  45. \setmainfont{$mainfont$}
  46. $endif$
  47. $if(sansfont)$
  48. \setsansfont{$sansfont$}
  49. $endif$
  50. $if(monofont)$
  51. \setmonofont{$monofont$}
  52. $endif$
  53. $if(mathfont)$
  54. \setmathfont{$mathfont$}
  55. $endif$
  56. \fi
  57. % use microtype if available
  58. \IfFileExists{microtype.sty}{\usepackage{microtype}}{}
  59. $if(geometry)$
  60. \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
  61. $endif$
  62. $if(natbib)$
  63. \usepackage{natbib}
  64. \bibliographystyle{plainnat}
  65. $endif$
  66. $if(biblatex)$
  67. \usepackage{biblatex}
  68. $if(biblio-files)$
  69. \bibliography{$biblio-files$}
  70. $endif$
  71. $endif$
  72. $if(listings)$
  73. \usepackage{listings}
  74. $endif$
  75. $if(lhs)$
  76. \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
  77. $endif$
  78. $if(highlighting-macros)$
  79. $highlighting-macros$
  80. $endif$
  81. $if(verbatim-in-note)$
  82. \usepackage{fancyvrb}
  83. $endif$
  84. $if(tables)$
  85. \usepackage{longtable}
  86. $endif$
  87. \usepackage{graphicx}
  88. \usepackage{caption}
  89. % We will generate all images so they have a width \maxwidth. This means
  90. % that they will get their normal width if they fit onto the page, but
  91. % are scaled down if they would overflow the margins.
  92. \makeatletter
  93. \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
  94. \else\Gin@nat@width\fi}
  95. \makeatother
  96. \let\Oldincludegraphics\includegraphics
  97. \renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}
  98. \ifxetex
  99. \usepackage[setpagesize=false, % page size defined by xetex
  100. unicode=false, % unicode breaks when used with xetex
  101. xetex]{hyperref}
  102. \else
  103. \usepackage[unicode=true]{hyperref}
  104. \fi
  105. \hypersetup{breaklinks=true,
  106. bookmarks=true,
  107. pdfauthor={$author-meta$},
  108. pdftitle={$title-meta$},
  109. colorlinks=true,
  110. urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
  111. linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
  112. pdfborder={0 0 0}}
  113. \urlstyle{same} % don't use monospace font for urls
  114. $if(links-as-notes)$
  115. % Make links footnotes instead of hotlinks:
  116. \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
  117. $endif$
  118. $if(strikeout)$
  119. \usepackage[normalem]{ulem}
  120. % avoid problems with \sout in headers with hyperref:
  121. \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
  122. $endif$
  123. \setlength{\parindent}{0pt}
  124. %\setlength{\parskip}{6pt plus 2pt minus 1pt}
  125. \setlength{\emergencystretch}{3em} % prevent overfull lines
  126. \usepackage{titling}
  127. \setlength{\droptitle}{-8em} % 將標題移動至頁面的上面
  128. \usepackage{fancyhdr}
  129. \usepackage{lastpage}
  130. \pagestyle{fancyplain}
  131. $if(numbersections)$
  132. \setcounter{secnumdepth}{5}
  133. $else$
  134. \setcounter{secnumdepth}{0}
  135. $endif$
  136. $if(verbatim-in-note)$
  137. \VerbatimFootnotes % allows verbatim text in footnotes
  138. $endif$
  139. $if(lang)$
  140. \ifxetex
  141. \usepackage{polyglossia}
  142. \setmainlanguage{$mainlang$}
  143. \else
  144. \usepackage[$lang$]{babel}
  145. \fi
  146. $endif$
  147. $for(header-includes)$
  148. $header-includes$
  149. $endfor$
  150. $if(title)$
  151. \title{$title$}
  152. $endif$
  153. \author{$for(author)$$author$$sep$ \and $endfor$}
  154. \date{$date$}
  155. %%%% 段落首行缩进两个字 %%%%
  156. \makeatletter
  157. \let\@afterindentfalse\@afterindenttrue
  158. \@afterindenttrue
  159. \makeatother
  160. \setlength{\parindent}{2em} %中文缩进两个汉字位
  161. %%%% 下面的命令重定义页面边距,使其符合中文刊物习惯 %%%%
  162. \addtolength{\topmargin}{-2pt}
  163. \setlength{\oddsidemargin}{0.63cm} % 3.17cm - 1 inch
  164. \setlength{\evensidemargin}{\oddsidemargin}
  165. \setlength{\textwidth}{14.66cm}
  166. \setlength{\textheight}{24.00cm} % 24.62
  167. %%%% 下面的命令设置行间距与段落间距 %%%%
  168. \linespread{1.4}
  169. % \setlength{\parskip}{1ex}
  170. \setlength{\parskip}{0.5\baselineskip}
  171. \begin{document}
  172. %%%% 定理类环境的定义 %%%%
  173. \newtheorem{example}{例} % 整体编号
  174. \newtheorem{algorithm}{算法}
  175. \newtheorem{theorem}{定理}[section] % 按 section 编号
  176. \newtheorem{definition}{定义}
  177. \newtheorem{axiom}{公理}
  178. \newtheorem{property}{性质}
  179. \newtheorem{proposition}{命题}
  180. \newtheorem{lemma}{引理}
  181. \newtheorem{corollary}{推论}
  182. \newtheorem{remark}{注解}
  183. \newtheorem{condition}{条件}
  184. \newtheorem{conclusion}{结论}
  185. \newtheorem{assumption}{假设}
  186. \newcommand{\tightlist}{%
  187. \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
  188. %%%% 重定义 %%%%
  189. \renewcommand{\contentsname}{目录} % 将Contents改为目录
  190. \renewcommand{\abstractname}{摘要} % 将Abstract改为摘要
  191. \renewcommand{\refname}{参考文献} % 将References改为参考文献
  192. \renewcommand{\indexname}{索引}
  193. \renewcommand{\figurename}{图}
  194. \renewcommand{\tablename}{表}
  195. \renewcommand{\appendixname}{附录}
  196. \pretitle{\begin{center}\Huge\bfseries\vskip 5em}
  197. \posttitle{\par\end{center}\vskip 24em}
  198. \preauthor{\begin{center}\Large\ttfamily}
  199. \postauthor{\end{center}}
  200. \predate{\par\large\centering}
  201. \postdate{\par}
  202. \title{Growth: 全栈增长工程师指南}
  203. \author{黄峰达(Phodal) \\ \href{https://github.com/phodal/growth-ebook}{https://github.com/phodal/growth-ebook}}
  204. \date{\today}
  205. \maketitle
  206. $for(include-before)$
  207. $include-before$
  208. $endfor$
  209. $if(toc)$
  210. {
  211. \newpage
  212. \hypersetup{linkcolor=black}
  213. \setcounter{tocdepth}{$toc-depth$}
  214. \tableofcontents
  215. }
  216. \newpage
  217. $endif$
  218. $body$
  219. $if(natbib)$
  220. $if(biblio-files)$
  221. $if(biblio-title)$
  222. $if(book-class)$
  223. \renewcommand\bibname{$biblio-title$}
  224. $else$
  225. \renewcommand\refname{$biblio-title$}
  226. $endif$
  227. $endif$
  228. \bibliography{$biblio-files$}
  229. $endif$
  230. $endif$
  231. $if(biblatex)$
  232. \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
  233. $endif$
  234. $for(include-after)$
  235. $include-after$
  236. $endfor$
  237. \end{document}