├── .gitignore ├── LICENSE ├── README.md ├── ltj-zhfonts.sty ├── main.pdf ├── main.tex └── pieces ├── b1.tex ├── b2.tex ├── b3.tex ├── b4.tex ├── m1.tex ├── m2.tex ├── m3.tex ├── m4.tex ├── m5.tex ├── p1.tex └── pieces-template.tex /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/latex 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=latex 3 | 4 | ### LaTeX ### 5 | ## Core latex/pdflatex auxiliary files: 6 | *.aux 7 | *.lof 8 | *.log 9 | *.lot 10 | *.fls 11 | *.out 12 | *.toc 13 | *.fmt 14 | *.fot 15 | *.cb 16 | *.cb2 17 | .*.lb 18 | 19 | ## Intermediate documents: 20 | *.dvi 21 | *.xdv 22 | *-converted-to.* 23 | # these rules might exclude image files for figures etc. 24 | # *.ps 25 | # *.eps 26 | # *.pdf 27 | 28 | ## Generated if empty string is given at "Please type another file name for output:" 29 | # .pdf 30 | 31 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 32 | *.bbl 33 | *.bcf 34 | *.blg 35 | *-blx.aux 36 | *-blx.bib 37 | *.run.xml 38 | 39 | ## Build tool auxiliary files: 40 | *.fdb_latexmk 41 | *.synctex 42 | *.synctex(busy) 43 | *.synctex.gz 44 | *.synctex.gz(busy) 45 | *.pdfsync 46 | 47 | ## Build tool directories for auxiliary files 48 | # latexrun 49 | latex.out/ 50 | 51 | ## Auxiliary and intermediate files from other packages: 52 | # algorithms 53 | *.alg 54 | *.loa 55 | 56 | # achemso 57 | acs-*.bib 58 | 59 | # amsthm 60 | *.thm 61 | 62 | # beamer 63 | *.nav 64 | *.pre 65 | *.snm 66 | *.vrb 67 | 68 | # changes 69 | *.soc 70 | 71 | # comment 72 | *.cut 73 | 74 | # cprotect 75 | *.cpt 76 | 77 | # elsarticle (documentclass of Elsevier journals) 78 | *.spl 79 | 80 | # endnotes 81 | *.ent 82 | 83 | # fixme 84 | *.lox 85 | 86 | # feynmf/feynmp 87 | #*.mf 88 | #*.mp 89 | *.t[1-9] 90 | *.t[1-9][0-9] 91 | #*.tfm 92 | 93 | #(r)(e)ledmac/(r)(e)ledpar 94 | *.end 95 | *.?end 96 | *.[1-9] 97 | *.[1-9][0-9] 98 | *.[1-9][0-9][0-9] 99 | *.[1-9]R 100 | *.[1-9][0-9]R 101 | *.[1-9][0-9][0-9]R 102 | *.eledsec[1-9] 103 | *.eledsec[1-9]R 104 | *.eledsec[1-9][0-9] 105 | *.eledsec[1-9][0-9]R 106 | *.eledsec[1-9][0-9][0-9] 107 | *.eledsec[1-9][0-9][0-9]R 108 | 109 | # glossaries 110 | *.acn 111 | *.acr 112 | *.glg 113 | *.glo 114 | *.gls 115 | *.glsdefs 116 | *.lzo 117 | *.lzs 118 | 119 | # uncomment this for glossaries-extra (will ignore makeindex's style files!) 120 | # *.ist 121 | 122 | # gnuplottex 123 | *-gnuplottex-* 124 | 125 | # gregoriotex 126 | *.gaux 127 | *.gtex 128 | 129 | # htlatex 130 | *.4ct 131 | *.4tc 132 | *.idv 133 | *.lg 134 | *.trc 135 | *.xref 136 | 137 | # hyperref 138 | *.brf 139 | 140 | # knitr 141 | *-concordance.tex 142 | # TODO Comment the next line if you want to keep your tikz graphics files 143 | #*.tikz 144 | #*-tikzDictionary 145 | 146 | # listings 147 | *.lol 148 | 149 | # luatexja-ruby 150 | *.ltjruby 151 | 152 | # makeidx 153 | *.idx 154 | *.ilg 155 | *.ind 156 | 157 | # minitoc 158 | *.maf 159 | *.mlf 160 | *.mlt 161 | *.mtc 162 | *.mtc[0-9]* 163 | *.slf[0-9]* 164 | *.slt[0-9]* 165 | *.stc[0-9]* 166 | 167 | # minted 168 | _minted* 169 | *.pyg 170 | 171 | # morewrites 172 | *.mw 173 | 174 | # nomencl 175 | *.nlg 176 | *.nlo 177 | *.nls 178 | 179 | # pax 180 | *.pax 181 | 182 | # pdfpcnotes 183 | *.pdfpc 184 | 185 | # sagetex 186 | *.sagetex.sage 187 | *.sagetex.py 188 | *.sagetex.scmd 189 | 190 | # scrwfile 191 | *.wrt 192 | 193 | # sympy 194 | *.sout 195 | *.sympy 196 | sympy-plots-for-*.tex/ 197 | 198 | # pdfcomment 199 | *.upa 200 | *.upb 201 | 202 | # pythontex 203 | *.pytxcode 204 | pythontex-files-*/ 205 | 206 | # tcolorbox 207 | *.listing 208 | 209 | # thmtools 210 | *.loe 211 | 212 | # TikZ & PGF 213 | *.dpth 214 | *.md5 215 | *.auxlock 216 | 217 | # todonotes 218 | *.tdo 219 | 220 | # vhistory 221 | *.hst 222 | *.ver 223 | 224 | # easy-todo 225 | *.lod 226 | 227 | # xcolor 228 | *.xcp 229 | 230 | # xmpincl 231 | *.xmpi 232 | 233 | # xindy 234 | *.xdy 235 | 236 | # xypic precompiled matrices and outlines 237 | *.xyc 238 | *.xyd 239 | 240 | # endfloat 241 | *.ttt 242 | *.fff 243 | 244 | # Latexian 245 | TSWLatexianTemp* 246 | 247 | ## Editors: 248 | # WinEdt 249 | *.bak 250 | *.sav 251 | 252 | # Texpad 253 | .texpadtmp 254 | 255 | # LyX 256 | *.lyx~ 257 | 258 | # Kile 259 | *.backup 260 | 261 | # gummi 262 | .*.swp 263 | 264 | # KBibTeX 265 | *~[0-9]* 266 | 267 | # TeXnicCenter 268 | *.tps 269 | 270 | # auto folder when using emacs and auctex 271 | ./auto/* 272 | *.el 273 | 274 | # expex forward references with \gathertags 275 | *-tags.tex 276 | 277 | # standalone packages 278 | *.sta 279 | 280 | # Makeindex log files 281 | *.lpz 282 | 283 | # REVTeX puts footnotes in the bibliography by default, unless the nofootinbib 284 | # option is specified. Footnotes are the stored in a file with suffix Notes.bib. 285 | # Uncomment the next line to have this generated file ignored. 286 | #*Notes.bib 287 | 288 | ### LaTeX Patch ### 289 | # LIPIcs / OASIcs 290 | *.vtc 291 | 292 | # glossaries 293 | *.glstex 294 | 295 | # my vim note style files. 296 | *.note 297 | 298 | # End of https://www.toptal.com/developers/gitignore/api/latex 299 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2022 Guoo Jehng Lee(qtnez) 2 | 3 | CC BY 4.0 license. 4 | 5 | https://creativecommons.org/licenses/by/4.0/deed.en 6 | https://creativecommons.org/licenses/by/4.0/legalcode 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LaTeX 正誤手冊 2 | 3 | 排版有許多慣例,甚至最後形成標準。這份文件主要就是排除違反慣例的情況。當然所謂慣例,除非形成標準,要不然仍然是會有爭議(就算是形成了標準,也還是有些人不願意遵守),這無所謂對、錯,這份文件的「正誤」也只是針對多數人遵從的慣例而言,不是完全的非黑即白。 4 | 5 | 但是關於 TeX/LaTeX 的語法,這就是非黑即白了,語法錯誤,嚴重的會使編譯中止,文件出不來,輕一點的是排版結果不符合預期。因此這份文件的所謂正誤,也包括了語法上的錯誤。 6 | 7 | ## 大綱: 8 | 9 | ### 基礎語法 10 | 11 | ### 套件使用 12 | 13 | ### 使用中文 14 | 15 | ### 數理式子 16 | 17 | ### 圖表處理 18 | 19 | ### 索引、文獻參考 20 | 21 | ### 其他、雜項 22 | 23 | 編譯所需字型,可以在: 24 | 25 | [luatexja-template/fonts at main · qtnez/luatexja-template (github.com)](https://github.com/qtnez/luatexja-template/tree/main/fonts) 26 | 27 | 下載安裝至作業系統。編譯需要 lualatex,由於標點符號的調整(ChineseJFM),因此最好使用 TeX Live 2021 的版本,否則需要自行安裝 [ChineseJFM](https://github.com/tanukihee/ChineseJFM)。 28 | -------------------------------------------------------------------------------- /ltj-zhfonts.sty: -------------------------------------------------------------------------------- 1 | % ltj-zhfonts.sty for zh_TW. 2 | 3 | \NeedsTeXFormat{LaTeX2e} 4 | \ProvidesPackage{ltj-zhfonts}[2021/06/06 chinese fonts for lualatex] 5 | \RequirePackage[match]{luatexja-fontspec} 6 | \RequirePackage[bf,sf]{titlesec} 7 | 8 | % ItalicFeatures={Scale=1.08} 可調整選項參數的字型的 scale。 9 | %\DeclareOption{myfont}{ 10 | \setmainjfont[BoldFont=Noto Sans CJK TC Medium, 11 | YokoFeatures = {JFM = zh_TW/quanjiao}, 12 | %AltFont={%{Range="20000-"2A6DF,Font=HanaMinB}, 13 | % {Range="2A700-"2B73F,Font=HanaMinB}, 14 | % {Range="2B740-"2B81F,Font=HanaMinB}, 15 | % {Range="FF1F-"FF1F,Font=HanaMinA}, 16 | % {Range="FF01-"FF01,Font=HanaMinA}, 17 | % {Range="3010-"3011,Font=HanaMinA}}, 18 | % BoldItalicFont=I.Ngaan, 19 | % ItalicFont=TW-MOE-Std-Kai, 20 | ]{I.MingCP} 21 | % ItalicFeatures={Scale=1.05}]{I.MingCP} 22 | \setsansjfont[BoldFont=Noto Sans CJK TC Medium, 23 | YokoFeatures = {JFM = zh_TW/quanjiao}, 24 | % BoldItalicFont=I.Ngaan, 25 | % ItalicFont=TW-MOE-Std-Kai, 26 | ]{Taipei Sans TC Beta Light} 27 | % ItalicFeatures={Scale=1.05}]{Taipei Sans TC Beta Light} 28 | \setmonojfont[BoldFont=Noto Sans CJK TC Medium, 29 | YokoFeatures = {JFM = zh_TW/quanjiao}, 30 | % BoldItalicFont=I.Ngaan, 31 | % ItalicFont=TW-MOE-Std-Kai, 32 | Scale=1.06]{cwTeXFangSong} 33 | % ItalicFeatures={Scale=1.05},Scale=1.06]{cwTeXFangSong} 34 | % 防止有些字一點明體沒有時取用。 35 | %\setjfontfamily\hminga{HanaMinA} 36 | %\setjfontfamily\hmingb{HanaMinB} 37 | %\newjfontfamily\nming{Noto Serif CJK TC Light} 38 | % \textit{\textbf{}} 太麻煩,另定義一個簡單指令。 39 | % 注意!要用 {\iyan 中文} 的方式取用。 40 | \setjfontfamily\iyan{I.Ngaan} 41 | %\setjfontfamily\kai{TW-MOE-Std-Kai}[Scale=1.05] 42 | %\setjfontfamily\fang{cwTeXFangSong}[Scale=1.06] 43 | %} 44 | 45 | % 會影響 footnote 的行間距,可引用 setspace 套件,預設在 footnote 會使用 46 | % singlespace。 47 | \renewcommand{\baselinestretch}{1.32} 48 | 49 | %\renewcommand{\prepartname}{第} 50 | %\renewcommand{\postpartname}{部} 51 | %\renewcommand{\prechaptername}{第} 52 | %\renewcommand{\postchaptername}{章} 53 | %\renewcommand{\presectionname}{}% 第 54 | %\renewcommand{\postsectionname}{}% 節 55 | \renewcommand{\contentsname}{目錄} 56 | 57 | %\newcommand{\zhtoday}{% 58 | % \kansuji\year 年 59 | % \kansuji\month 月 60 | % \kansuji\day 日} 61 | 62 | \renewcommand{\figurename}{圖} 63 | \renewcommand{\tablename}{表} 64 | 65 | %\ExecuteOptions{myfont} 66 | 67 | %\ProcessOptions\relax 68 | \relax 69 | \endinput 70 | -------------------------------------------------------------------------------- /main.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TeXtw/latex-convention/0f9e2df8d0b54bca128c26c65189132314c5c374/main.pdf -------------------------------------------------------------------------------- /main.tex: -------------------------------------------------------------------------------- 1 | % !TEX program = LuaLaTeX + luatex-ja 2 | % Copyright © 2022 Guoo Jehng Lee 3 | % CC BY 4.0 license. 4 | % Chat: https://t.me/TWTUG (Taiwan TeX User Group) 5 | 6 | \documentclass[11pt,a4paper]{article} 7 | % which package used. 8 | %\listfiles 9 | \usepackage[a4paper,textwidth=420pt,textheight=680pt]{geometry} 10 | % 定義 input 路徑 11 | \makeatletter 12 | \def\input@path{{./pieces/}} 13 | % \def\input@path{{./figures/}{./pieces/}} 14 | \makeatother 15 | 16 | % siunitx 和 physics 會有衝突 \qty 要用 \SI 取代。 17 | \usepackage[svgnames]{xcolor} 18 | \usepackage{ltj-zhfonts,parskip,mdframed,mparhack,amsmath,siunitx,textcomp, 19 | setspace,upgreek} 20 | \usepackage[time=Chinese,style={Traditional,Normal}]{zhnumber} 21 | \usepackage{libertinus} 22 | %\usepackage[math-style=ISO]{unicode-math} 23 | 24 | % 定義正誤條邊框顏色及「回目錄」 button 顏色 25 | \definecolor{britishracinggreen}{rgb}{0.0, 0.26, 0.15} 26 | \definecolor{bulgarianrose}{rgb}{0.28, 0.02, 0.03} 27 | 28 | % 正誤條的環境定義: 29 | % 章節後不會留有正常空白,需要 startcode 校正。 30 | \newmdenv[linecolor=red,frametitle=誤:,leftmargin=1em,rightmargin=1em, 31 | startcode=\leavevmode,topline=false,bottomline=false,linewidth=1.2pt, 32 | skipabove=2ex]{Wrong} 33 | \newmdenv[linecolor=britishracinggreen,frametitle=正:,leftmargin=1em, 34 | rightmargin=1em,topline=false,bottomline=false,linewidth=1.2pt, 35 | skipabove=2ex,skipbelow=1ex]{Right} 36 | 37 | % 定義程式碼 38 | \newmdenv[leftmargin=1em,rightmargin=1em,linecolor=LightGrey!60, 39 | linewidth=1.5pt,skipabove=2ex,skipbelow=.5ex, 40 | backgroundcolor=LightGrey!20]{Code} 41 | 42 | % 回目錄的定義 43 | \newcommand{\back}{% 44 | \begin{flushright} 45 | \hyperlink{contents}{\textcolor{bulgarianrose}{\iyan 回目錄}} 46 | \end{flushright}} 47 | 48 | \usepackage[pdfstartview={FitH},pdfencoding={auto}, 49 | pdfauthor={李果正 Guoo Jehng Lee},pdfsubject={LaTeX 正誤手冊}, 50 | pdftitle={LaTeX 正誤手冊},pdfkeywords={LaTeX, typesetting, conventions}, 51 | bookmarksopen={true}]{hyperref} 52 | 53 | % \zhtoday 定義於 zhnumber 套件。 54 | %\title{\textsf{\textbf{\LaTeX 正誤手冊}}} 55 | \title{\textsf{\textbf{\LaTeX \iyan 正誤手冊}}} 56 | \author{李果正 Guoo Jehng Lee} 57 | \date{\zhtoday} 58 | 59 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 60 | %%%%%%%%% 本文開始 %%%%%%%%% 61 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 62 | 63 | \begin{document} 64 | 65 | \maketitle 66 | 67 | 排版有許多慣例,甚至最後形成標準。這份文件主要就是排除違反慣例的情況。當 68 | 然所謂慣例,除非形成標準,要不然仍然是會有爭議(就算是形成了標準,也還是 69 | 有些人不願意遵守),這無所謂對、錯,這份文件的「正誤」也只是針對多數人遵 70 | 從的慣例而言,不是完全的非黑即白。 71 | 72 | 但是關於\TeX/\LaTeX 的語法,這就是非黑即白了,語法錯誤,嚴重的會使編譯中 73 | 止,文件出不來,輕一點的是排版結果不符合預期。因此這份文件的所謂正誤,也 74 | 包括了語法上的錯誤。 75 | 76 | 以下每個小節都是一個獨立的單元,為了索引方便,在每一小節末的右手邊 77 | ,會有一個「回目錄」的文字 button,可以馬上回到目錄,利於查找,至於到了 78 | 目錄,目錄本身的各小節本就有超連結的功能。為了閱讀方便,目錄是放在文件的 79 | 最後,當成索引使用。 80 | 81 | \section{基礎語法} 82 | \label{sec:syntax} 83 | 84 | \input{b1} 85 | \input{b2} 86 | \input{b3} 87 | \input{b4} 88 | 89 | \section{套件使用} 90 | \label{sec:package} 91 | 92 | \input{p1} 93 | 94 | \section{使用中文} 95 | \label{sec:chinese} 96 | 97 | \section{數理式子} 98 | \label{sec:math} 99 | 100 | \input{m1} 101 | \input{m2} 102 | \input{m3} 103 | \input{m4} 104 | \input{m5} 105 | 106 | \section{圖表處理} 107 | \label{sec:figure} 108 | 109 | \section{索引、文獻參考} 110 | \label{sec:index} 111 | 112 | \section{其他、雜項} 113 | \label{sec:miscellaneous} 114 | 115 | \clearpage 116 | \hypertarget{contents}{} 117 | \tableofcontents 118 | 119 | \end{document} 120 | -------------------------------------------------------------------------------- /pieces/b1.tex: -------------------------------------------------------------------------------- 1 | \subsection{單位前需要小空白} 2 | \label{sub:unit} 3 | 4 | \begin{Wrong} 5 | \begin{verbatim} 6 | 台灣南北的長度大約 394km,東西上大闊度大約 144km。 7 | \end{verbatim} 8 | 9 | 台灣南北的長度大約 394km,東西上大闊度大約 144km。 10 | \end{Wrong} 11 | 12 | \begin{Right} 13 | \begin{verbatim} 14 | 台灣南北的長度大約 394\,km,東西上大闊度大約 144\,km。 15 | \end{verbatim} 16 | 17 | 台灣南北的長度大約 394\,km,東西上大闊度大約 144\,km。 18 | \end{Right} 19 | 20 | 單位前需要一個小空白(插入\verb|\,|)。可以參考\href{https://github.com/josephwright/siunitx}{\sf siunitx}套件的例子。 21 | 如果不想傷這個腦筋,可以引用{\sf siunitx}套件,依照它的使用方法來表現數字及單位, 22 | 這樣就可以全文一致,不必一個一個去手動修正。 23 | 24 | 有規則就會有例外,非字母的符號(準)單位,例如溫度(24\textcelsius)、百分號(10\%),數字和符號間是不留空白的。a.m./p.m.\/這類表示上下午的也不留空白。\footnote{正式文件一般主張要留空白,2:45\,p.m.,而且時區要用小括號括住,小括號前要留空白,2:45\,p.m.\,(EST)。} 25 | 26 | {\sf SI}(Système International d'Unités)對此有異議,認為只要是單位就得留白(\SI{24}{\degreeCelsius}、\SI{10}{\percent}),例外是單純的角度符號(\ang{30;8;22})就需要緊密。另外 \%\ 並非是{\sf SI}中認定的單位(但{\sf siunitx}中有定義百分號)。 27 | 在一般的寫作文件,對溫度度數及百分號不少人還是持不要空白的風格。\footnote{Chicago style主張不要空白,APA及ACS style主張要空白。請參考:\url{https://blogs.millersville.edu/bduncan/numbers/}。} 28 | 29 | 好像有點亂,所以寫正式文件時,有style manual的話,還是要詳細讀一讀,upstream的要求比你的喜好重要。如果不知何去何從,最簡單的方式就是依標準來。 30 | 31 | \marginpar{\back} 32 | -------------------------------------------------------------------------------- /pieces/b2.tex: -------------------------------------------------------------------------------- 1 | \subsection{一些特殊字元不能直接鍵入} 2 | \label{sub:special} 3 | 4 | \begin{Wrong} 5 | \begin{verbatim} 6 | TeX 裡頭有一些特殊字元是無法直接鍵入的,例如倒斜線 \,那是指令的引頭字元,直接鍵入編譯也不會過。 7 | \end{verbatim} 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | 那麼這類字元要如何鍵入呢?可以使用 \ 去 escape 它,但唯獨這個倒斜線不行,要用 \textbackslash 來鍵入,或者進入數學模式 $\backslash$,這些指令都滿長的。另有簡單的方式,就是直接取出字元來 \char`\\ 就可以了(那個 ` 是左單引號)。 13 | \end{verbatim} 14 | \end{Right} 15 | 16 | 以下說明各種特殊符號的鍵入方式。至於取巧用 \verb|\char`\\| 的方式,在章節標題時 17 | 最好不用,因為 pdf bookmarks 的顯示會不正常(無法正確轉換為ascii或UTF-16BE)。 18 | 19 | \vspace{.5\baselineskip} 20 | \begin{center} 21 | \small 22 | \setstretch{1.2} 23 | \begin{tabular}{llll} 24 | \hline 25 | 符號 & 作用 & 文稿上使用 & \LaTeX\ 的替代指令 \\ 26 | \hline 27 | \textbackslash & 下排版命令 & \verb|$\backslash$| & \verb|\textbackslash|\\ 28 | \% & 註解 & \verb|\%| & NA \\ 29 | \# & 定義巨集 & \verb|\#| & NA \\ 30 | \~{} & 產生一個空白 & \verb|\~{}| & \verb|\textasciitilde| \\ 31 | \$ & 進入(離開)數學模式 & \verb|\$| & \verb|\textdollar| \\ 32 | \_{} & 數學模式中產生下標字 & \verb|\_{}| & \verb|\textunderscore| \\ 33 | \^{} & 數學模式中產生上標字 & \verb|\^{}| & \verb|\textasciicircum| \\ 34 | \{ & 標示命令的作用範圍 & \verb|\{| & \verb|\textbraceleft|\\ 35 | \} & 標示命令的作用範圍 & \verb|\}| & \verb|\textbraceright|\\ 36 | \textless & 數學模式中的小於符號 & \verb|$<$| & \verb|\textless| \\ 37 | \textgreater & 數學模式中的大於符號 & \verb|$>$| & \verb|\textgreater| \\ 38 | \textbar & OT1,數學模式中才能正確顯示 & \verb+$|$+ & \verb|\textbar| \\ 39 | \& & 表格中的分隔符號 & \verb|\&| & NA \\ 40 | \hline 41 | \end{tabular} 42 | \end{center} 43 | \vspace{.5\baselineskip} 44 | 45 | \marginpar{\back} 46 | -------------------------------------------------------------------------------- /pieces/b3.tex: -------------------------------------------------------------------------------- 1 | \subsection{改變字型大小要用 \texttt{\textbackslash par} 來調整行距} 2 | 3 | \def\mytext{% 4 | 《說文解字》書名。東漢許慎撰,三十卷,為我國第一部有系統分析字形及考究字源的字書。按文字形體及偏旁構造分列五百四十部,首創部首編排法?} 5 | 6 | \begin{Wrong} 7 | \begin{verbatim} 8 | \begin{document} 9 | \mytext 10 | 11 | {\footnotesize \mytext} 12 | \end{document} 13 | \end{verbatim} 14 | \mytext 15 | 16 | {\footnotesize \mytext} 17 | \end{Wrong} 18 | 19 | \begin{Right} 20 | \begin{verbatim} 21 | \begin{document} 22 | \mytext 23 | 24 | {\footnotesize \mytext\par} 25 | \end{document} 26 | \end{verbatim} 27 | \mytext 28 | 29 | {\footnotesize \mytext\par} 30 | \end{Right} 31 | 32 | 那個 \verb|\mytext| 是事先定義好的一段文字。在改變字型大小時要注意它的行距,它會依原先的行距來排版,要校正這個問題,要在 group 的 \verb|}| 之前先換成下一個段落。 33 | 34 | 不做這樣的調整的話,例子裡頭的小字(footnotesize)的段落,它的行距太大,因為是依原先normalsize的行距來排版(\TeX 是依段落來斷行的,在此之前一切資訊未定)。小字應依小字的比例來縮小行距,同理改變成大字時,也應依大字的行距來照比例調大。請參考\href{https://tex.stackexchange.com/questions/444039/why-do-i-have-to-use-par-if-i-change-font-size-withing-a-group-scope}{\textsf{StackExchange}}上的討論。 35 | 36 | \marginpar{\back} 37 | -------------------------------------------------------------------------------- /pieces/b4.tex: -------------------------------------------------------------------------------- 1 | \subsection{英文句點後的空白} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | Please see Appendix A. We will be there soon. 6 | \end{verbatim} 7 | Please see Appendix A. We will be there soon. 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | Please see Appendix A\@. We will be there soon. 13 | \end{verbatim} 14 | Please see Appendix A\@. We will be there soon. 15 | \end{Right} 16 | 17 | \LaTeX 會在英文文章的一個句子結束和另一個句子開始的中間,自動調整成較大一點的空白, 18 | 這可以增加文章的易讀性。所謂一個句子結束,例如:句點(.)、問號(?)、驚嘆號(!)及 19 | 冒號(:)之後。通常句子結束的最後一個英文字母是小寫的,但這個例子是一個特殊的例外,句點 20 | 之前是大寫的英文字母,\LaTeX 不會判斷成句子結尾,因此不會加大其後的空白,這時我們只好手動去告知\LaTeX 這是句子結束。 21 | 22 | 相同的情形發生在以下的段落: 23 | 24 | \begin{Code} 25 | \small 26 | \setstretch{1.0} 27 | \begin{verbatim} 28 | Aesop lived in Ancient Greece in the 6th Century BC\@. His fables are 29 | usually short and end with a moral. 30 | \end{verbatim} 31 | \end{Code} 32 | 33 | 相反的情形,句點前的字母是小寫的,但卻不是句子的結束,這時怎麼辦?這時可以在句點結束後直接加上 \verb|\ |(倒斜線後是一個空白),這樣就會抑制\LaTeX 去判斷成句子結束,例如: 34 | 35 | \begin{Code} 36 | \small 37 | \begin{verbatim} 38 | e.g.\ this is a test. 39 | \end{verbatim} 40 | \end{Code} 41 | 42 | 或者採用Chicago style的方式,就是在{\tt e.g.}後加一個英文逗點({\tt e.g.,}),這樣就不會被判斷成句子結束了(類似的例子還有{\tt i.e.,})。其他有使用到縮寫字的場合,例如:`Dr.'、`etc.'、`vs.'、`Fig.'、`cf.'、`Mr.'、`Mrs.',這些都不是代表句子結束,所以,要插入一個正常空白。 43 | 44 | 有人不喜歡這個規則(例如法國人),如果要中止這種判斷的話,可以在文稿的導言區加上 \verb|\frenchspacing|。 45 | 46 | \marginpar{\back} 47 | -------------------------------------------------------------------------------- /pieces/m1.tex: -------------------------------------------------------------------------------- 1 | \subsection{數理式子需要適當的空白} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | \[L(s)=\int^b_a\sqrt{1+(f'(x))^2}dx.\] 6 | \end{verbatim} 7 | \[L(s)=\int^b_a\sqrt{1+(f'(x))^2}dx.\] 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | \[L(s)=\int^b_a \! \sqrt{1+(f'(x))^2}\,\text{d}x.\] 13 | \end{verbatim} 14 | \[L(s)=\int^b_a \! \sqrt{1+(f'(x))^2} \, \text{d}x.\] 15 | \end{Right} 16 | 17 | 微分符號本身是一種運算子(operator),並不是變數,在數學模式\LaTeX 需要 18 | 數學斜體的變數來和其它字母做區分,他在此的地位類似單位,之前要留一個小空 19 | 白,而且必需使用正體(upright),不能使用數學斜體(italic)。這在\href{https://saso.gov.sa/ar/mediacenter/public_multimedia/Documents/SASO-ISO-800000-2-2020-E.pdf}{ISO 80000-2}標準裡頭也是如此認定。 20 | 21 | 但是這個微分符號是否要正體是有爭議的,大體而言,數學家較多偏向用數學 22 | 斜體(包括 Knuth 本人也是使用數學斜體),物理學家較多偏向 23 | 用正體。\footnote{可以參考\href{https://tex.stackexchange.com/questions/14821/whats-the-proper-way-to-typeset-a-differential-operator}{\sf StackExchange}的討論。}不過,既然有標準出現了,大家還是盡量遵循標準比較恰當。\footnote{Knuth在設計\TeX 的時候,這個標準還沒有出現。} 24 | 25 | 使用 \verb|\text{d}| 需要{\sf amsmath}套件,否則要使用 \LaTeX 內建的 \verb|\mathrm{d}|。另外{\sf physics}套件有提供 \verb|\dd, \dv| 的方便短指令。 26 | 另有一種取巧的方式,就是使用 \verb|\mbox{d}|,被 \verb|\mbox{}| 包住的文字都會使用 27 | 正體。這幾種方式會有小差異,\verb|\mbox{}| 的方式盡量避免,請試著編譯\\ 28 | {\small \verb|$x^{\mathrm{a test}}x^{\mbox{a test}}x^{\text{a test}}x^{\textrm{a test}}$|}\\ 29 | 看出來的結果就知道了。 30 | 31 | 以下列出有關空白的指令: 32 | 33 | \vspace{.5\baselineskip} 34 | \begin{center} 35 | \small 36 | \setstretch{1.2} 37 | \begin{tabular}{llll} 38 | \hline 39 | 指令 & 作用 & 指令 & 作用 \\ 40 | \hline 41 | \verb|\quad| & 空出一個 em 單位的空白 & \verb|\qquad| & 空出兩個 em 的空白 \\ 42 | \verb|\,| & 加入 1/6 quad 的空白 & \verb|\!| & 減去 1/6 quad 的空白 \\ 43 | \verb|\;| & 加入 5/18 quad 的空白 & \verb|\:| & 加入 2/9 quad 的空白\\ 44 | \hline 45 | \end{tabular} 46 | \end{center} 47 | \vspace{.5\baselineskip} 48 | 49 | 這裡要注意的地方是,自從\LaTeX\ 2020-10-01發行後,一些以往只能用在數學模式的 50 | 空白指令,現在已經可以用在文字模式及數學模式了。在此之前, 51 | \verb|\,|、\verb|\quad| 及 \verb|\qquad| 可以用在一般的文字模式及數學模式, 52 | 其他的只能使用在數學模式中。 53 | 54 | \marginpar{\back} 55 | -------------------------------------------------------------------------------- /pieces/m2.tex: -------------------------------------------------------------------------------- 1 | \subsection{數學模式下使用正體字的情況} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | $cos 2x=cos^2x-sin^2x$ 6 | \[lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\] 7 | \end{verbatim} 8 | $cos 2x=cos^2x-sin^2x$ 9 | \[lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\] 10 | \end{Wrong} 11 | 12 | \begin{Right} 13 | \begin{verbatim} 14 | $\cos 2x=\cos^2x-\sin^2x$ 15 | \[\lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\] 16 | \end{verbatim} 17 | $\cos 2x=\cos^2x-\sin^2x$ 18 | \[\lim_{n \to \infty}\sum_{i=1}^n{\frac{1}{n}}\] 19 | \end{Right} 20 | 21 | 數學模式下,為了容易區分字母所代表的意義,大原則是變數使用數學斜體。 22 | 但不是變數的情況,會有種種的慣例或標準來規範。 23 | 24 | 這裡整理一下{\sf ISO 80000-2}標準的相關說明: 25 | 26 | \begin{itemize} 27 | \item 變數(variables),例如$x$、$y$……等等。變動的數字(running numbers),例如$x_i$中的$i$。要用數學斜體(italic)。 28 | \item 由於敘述上產生的函數,例如$f$、$g$,要用數學斜體。但已經是明確定義的固定函數,要用正體,例如$\sin$、$\exp$、$\ln$、$\lim$、$\log$……等等,要用正體。 29 | \item 數學常數,例如$\text{e}=\num{2.718281828}\cdots$、$\uppi=\num{3.141592}\cdots$……等等,e 及$\uppi$要用正體。 30 | \item 已經完整定義的運算子,例如微分符號($\text{d}x/\text{d}y$)、加減乘除以及數字,要用正體。 31 | \end{itemize} 32 | 33 | \marginpar{\back} 34 | 35 | -------------------------------------------------------------------------------- /pieces/m3.tex: -------------------------------------------------------------------------------- 1 | \subsection{二種冒號(colon)} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | \[\{\, x \colon x \notin x \,\}\] 6 | \[f : x \to x^2\] 7 | \end{verbatim} 8 | \[\{\, x \colon x \notin x \,\}\] 9 | \[f : x \to x^2\] 10 | \end{Wrong} 11 | 12 | \begin{Right} 13 | \begin{verbatim} 14 | \[\{\, x : x \notin x \,\}\] 15 | \[f \colon x \to x^2\] 16 | \end{verbatim} 17 | \[\{\, x : x \notin x \,\}\] 18 | \[f \colon x \to x^2\] 19 | \end{Right} 20 | 21 | 二種(英文)冒號 \verb|:| 和 \verb|\colon| 表現出來,在形狀上雖然相同,但是置放位置不同。 22 | 通常 \verb|:| 是用在集合描述(關係運算符號),而 \verb|\colon| 是當成標點符號, 23 | 常用在映射表示。\footnote{請參考\href{https://tex.stackexchange.com/questions/37789/using-colon-or-in-formulas}{\sf StackExchange}的討論。} 24 | 另外,比例通常用 \verb|:|,例如$x:y:z = 3:4:5$。 25 | 26 | \marginpar{\back} 27 | -------------------------------------------------------------------------------- /pieces/m4.tex: -------------------------------------------------------------------------------- 1 | \subsection{數式環境下上不可留白} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | 這是一個測試。 6 | 7 | \begin{equation*} 8 | g(x)=\sqrt{9-x^2} 9 | \end{equation*} 10 | \end{verbatim} 11 | 這是一個測試。 12 | 13 | \begin{equation*} 14 | g(x)=\sqrt{9-x^2} 15 | \end{equation*} 16 | \end{Wrong} 17 | 18 | \begin{Right} 19 | \begin{verbatim} 20 | 這是一個測試。 21 | \begin{equation*} 22 | g(x)=\sqrt{9-x^2} 23 | \end{equation*} 24 | \end{verbatim} 25 | 這是一個測試。 26 | \begin{equation*} 27 | g(x)=\sqrt{9-x^2} 28 | \end{equation*} 29 | \end{Right} 30 | 31 | 這裡會發現留有空白行的{\tt equation}環境,上面會多空出更多的空白行出來。 32 | 要在數式環境變動上下空白,要由特定的指令來完成,不能手動的去留個空白行, 33 | 因為這個空白行會被\TeX 解釋成起新段落。 34 | 35 | 調整數式上下的空白,可以使用特定的指令,例如: 36 | 37 | \begin{Code} 38 | \small 39 | \setstretch{1.0} 40 | \begin{verbatim} 41 | \abovedisplayshortskip=10pt 42 | \belowdisplayshortskip=10pt 43 | \begin{equation} 44 | g(x)=\sqrt{9-x^2} 45 | \end{equation} 46 | \end{verbatim} 47 | \end{Code} 48 | 49 | 同樣的情況發生在 \verb|\[...\]|,上下亦不可多出空白行。隨文數式, 50 | 因為它是要「隨文」的,因此在 \verb|\(...\)| 或是 \verb|$...$| 前後則要有個空白, 51 | 同義的 \verb|\begin{math}...\end{math}| 同樣是不能有多餘的空白行的。{\sf amsmath}套 52 | 件,有針對 \verb|\[...\]| 做調整,會回復正常的空白,但習慣上還是養成不要留有空白行, 53 | 因為這並沒有對所有的數式環境做調整。 54 | 55 | \marginpar{\back} 56 | -------------------------------------------------------------------------------- /pieces/m5.tex: -------------------------------------------------------------------------------- 1 | \subsection{數學模式中改變字體大小} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | $\huge f(x,y)=\frac{3(x+y)y}{(2xy-7)}$ 6 | \end{verbatim} 7 | $\huge f(x,y)=\frac{3(x+y)y}{(2xy-7)}$ 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | \huge $f(x,y)=\frac{3(x+y)y}{(2xy-7)}$ 13 | \end{verbatim} 14 | \huge $f(x,y)=\frac{3(x+y)y}{(2xy-7)}$ 15 | \end{Right} 16 | 17 | 在數學模式中,不能使用正常文字模式中改變字體大小的指令,這不僅不能改變字體大小, 18 | 而且編譯時還會出現錯誤訊息: 19 | 20 | \begin{Code} 21 | \small 22 | \begin{verbatim} 23 | LaTeX Font Warning: Command \huge invalid in math mode on input line 38. 24 | \end{verbatim} 25 | \end{Code} 26 | 27 | 要改變數學模式中的字體大小,可以使用數學模式下專用的指令,或者將改變字體大小的指令移出 28 | 數學模式外。以下是能用於數學模式的指令: 29 | 30 | \vspace{.5\baselineskip} 31 | \begin{center} 32 | \small 33 | \setstretch{1.2} 34 | \begin{tabular}{ll} 35 | \hline 36 | 指令 & 作用 \\ 37 | \hline 38 | \verb|\displaystyle| & 正常大小字體的展式數式 \\ 39 | \verb|\scriptstyle| & 縮小成上下標字體的大小 \\ 40 | \verb|\scriptscriptstyle| & 縮小二倍上下標字體的大小 \\ 41 | \verb|\textstyle| & 回復成正常字體大小 \\ 42 | \hline 43 | \end{tabular} 44 | \end{center} 45 | \vspace{.5\baselineskip} 46 | 47 | 有引用{\sf amsmath}套件的話,可以在 \verb|\text{}| 中使用文字模式下的改變字體大小的指令: 48 | 49 | \begin{Code} 50 | \small 51 | \setstretch{1.0} 52 | \begin{verbatim} 53 | \usepackage{amsmath} 54 | ... 55 | $\text{\huge $f(x,y)=\frac{3(x+y)y}{(2xy-7)}$}$ 56 | \end{verbatim} 57 | \end{Code} 58 | 59 | 引用{\sf graphics}套件,可以在數學模式中使用 \verb|\scalebox| 來改變字體的大小。 60 | 61 | \begin{Code} 62 | \small 63 | \setstretch{1.0} 64 | \begin{verbatim} 65 | \usepackage{graphicx} 66 | \newcommand*{\Scale}[2][4]{\scalebox{#1}{\ensuremath{#2}}} 67 | ... 68 | $\Scale[1.2]{f(x,y)=\frac{3(x+y)y}{(2xy-7)}}$ 69 | \end{verbatim} 70 | \end{Code} 71 | 72 | \marginpar{\back} 73 | -------------------------------------------------------------------------------- /pieces/p1.tex: -------------------------------------------------------------------------------- 1 | \subsection{重複載入的套件} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | \usepackage{hyperref} 6 | \usepackage{url} 7 | \end{verbatim} 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | \usepackage{hyperref} 13 | \end{verbatim} 14 | \end{Right} 15 | 16 | 在\LaTeX 的使用上,引用套件(package)是避免不了,但\LaTeX 的套件,超過 17 | 四千個,這麼多的套件,其中難免會有衝突。很不幸的,並沒有很好的工具來預知 18 | 哪些套件會衝突,只能靠使用過的人的經驗及自行使用時的發現。 19 | 20 | 一些套件會預設載入其他套件,這樣這些預設會載入的套件就無需重複載入了。不 21 | 過,也很不幸的,並沒有一個完美的工具預知某套件會預設載入哪些其他的套件, 22 | 除非你打開這個套件的原始碼,去看看預設載入了什麼套件。或者加入一行 \verb|\listfiles| 於 23 | 其他套件載入之前,然後編譯後開啟 \verb|*.log| 檔,找到 \verb|*File List*| 的地方, 24 | 會列出所使用的套件及其版本。\footnote{有一個很dirty的小程式{\tt ltxpkg},可以在\url{https://github.com/qtnez/luatexja-template/tree/main/tools}找到。} 25 | 26 | 這個例子裡頭,{\sf hyperref}套件,預設就是會載入{\sf url}套件,因此無需 27 | 重複載入。那麼如果想傳參數給{\sf url}時怎麼辦?這時可以在{\sf hyperef}之前載入 28 | {\sf url}並指定參數。 29 | 30 | \begin{Code} 31 | \small 32 | \setstretch{1.0} 33 | \begin{verbatim} 34 | \documentclass{article} 35 | \usepackage[hyphens]{url} 36 | \usepackage{hyperref} 37 | \end{verbatim} 38 | \end{Code} 39 | 40 | 當然,新一點的套件都會設計得比較周詳,在套件載入後,還可以用 \verb|\*setup| 之類的指令來變更及設定一些選項的參數。例如 {\sf hyperref} 的 \verb|\hypersetup| 以及 {\sf mdframed} 的 \verb|\mdsetup|。 41 | 42 | \marginpar{\back} 43 | -------------------------------------------------------------------------------- /pieces/pieces-template.tex: -------------------------------------------------------------------------------- 1 | \subsection{此條的簡述標題} 2 | 3 | \begin{Wrong} 4 | \begin{verbatim} 5 | 6 | \end{verbatim} 7 | 8 | \end{Wrong} 9 | 10 | \begin{Right} 11 | \begin{verbatim} 12 | 13 | \end{verbatim} 14 | 15 | \end{Right} 16 | 17 | \marginpar{\back} 18 | --------------------------------------------------------------------------------