View on GitHub

Begin-Latex-in-minutes

馃摐 Brief Intro to LaTeX for beginners that helps you use LaTeX with ease.

English 路 涓枃 路 Espa帽olPortugu锚sFran莽ais袪褍褋褋泻懈泄Deutsch鏃ユ湰瑾Polski


瀛︿範 LaTeX 浠庣幇鍦ㄥ紑濮

璇戣呭墠瑷锛 鏈汉灏介噺鎸夌収鍘熶綔鑰呭師鎰忕炕璇戯紝浣嗘按骞虫湁闄愶紝濡傛湁缈昏瘧涓嶅Ε涔嬪锛屾杩庢寚姝c傚鏋滄偍鍠滄鏈枃锛屾杩庡垎浜粰鏇村浜虹湅鍒般

(Chinese translator鈥檚 Acknowledgement: I try to translate this guide as the original meaning of the author.But because of the level limited, if the translation is inappropriate, welcome to modified or added.If you like this guide, please share to more people.)

鍓嶈█: 浠ヤ笅鎵鍐欏潎鏉ヨ嚜浜庝綔鑰呯殑澶у缁忓巻浠ュ強闃呰浜嗗緢澶氭潗鏂欎箣鍚庣殑鎰熸偀銆備綔鑰呬笉鏄繖鏂归潰鐨勪笓瀹讹紝浠呬粎鏄竴涓杩欓棬璇█鏈夋瀬澶х儹鎯呯殑瀛︾敓銆備换浣曚汉閮藉彲浠ュ湪闂鍒嗗尯锛坕ssue锛変腑寮鍚柊鐨勮璁猴紝鎴栬呭闇瑕佷慨鏀规垨娣诲姞鍐呭鐢宠淇敼锛坧ull request 锛夈傚鏋滀綘璁や负浣滆呯殑宸ヤ綔鏄湁浠峰肩殑锛屾杩庤繘琛鎹愯禒

鐩綍

LaTeX 鏄粈涔堬紵

LaTeX 鏄竴绉嶇敤浜庤繘琛岄珮璐ㄩ噺鎺掔増鐨勬枃妗e鐞嗙郴缁熴侺aTeX 璇讳綔 芦Lah-tech禄 鎴栬 芦Lay-tech禄 (鍜 芦blech禄 鐨勯煹姣嶄竴鏍)銆傚畠琚箍娉涚殑鐢ㄤ簬鎺掔増澶т腑鍨嬬瀛︽妧鏈枃鐚紝闄ゆ涔嬪锛屽畠鍑犱箮鑳界敤浜庢帓鐗堜换浣曞舰寮忕殑鍑虹増鐗┿

涓轰粈涔堣鐢 LaTeX锛

LaTeX 骞朵笉鏄病鏈夌己鐐癸紝浣嗗畠浠嶇劧鍊煎緱瀛︿範銆

瀹夎 LaTeX

浣犲皢闇瑕佷互涓嬪嚑涓蒋浠讹細

  1. LaTeX 鐨勫彂琛岀増锛 鎴戜娇鐢 windows 鐗堢殑 MiKTeX
  2. LaTeX 缂栬緫鍣細 鎴戜娇鐢 TeXMaker 鏉ョ紪杈戞枃浠讹紝褰撶劧浣跨敤浠讳綍涓涓枃鏈紪杈戝櫒鍧囧彲浠ュ垱寤哄苟淇敼 LaTeX 鏂囦欢銆
  3. PDF 鏌ョ湅鍣細 (鍙) 浠讳綍 PDF 鏌ョ湅鍣ㄥ潎鍙紝鍙栧喅浜庝綘鐨勫枩濂姐

鍙﹀锛屼綘闇瑕侀夋嫨涓涓缂栬瘧鍣銆傚ぇ澶氭暟缂栬緫浜哄憳鐨勯粯璁ょ紪璇戝櫒鏄 pdfLaTeX 锛屼絾濡傛灉浣犳兂鍦ㄤ綘鐨勭郴缁熶腑浣跨敤 Unicode 鎴 TTF / OTF 瀛椾綋锛屼綘闇瑕 LuaLaTeX 銆

鎴栬呬綘鍙互閫夋嫨鍦ㄧ嚎杞欢锛屾瘮濡 ShareLaTeX锛 浣犲彲浠ュ湪鏇村宸ュ叿涓鑺備腑鐪嬪埌鏇村閫夋嫨銆

绗竴涓 LaTeX 鏂囦欢

璁╂垜浠敤 LaTeX 涓紪鍐欎紶缁熺殑 Hello World銆 濡傛灉浣犺濂戒簡 TexMaker 锛岄鍏堝垱寤轰竴涓悗缂鍚嶄负 .tex 鐨勬柊鏂囦欢銆傜劧鍚庡湪鏂囦欢閲屾暡鍏ュ涓嬩唬鐮佸苟杩愯蹇熸瀯寤( quick build )銆傚浜庡叾浠 LaTeX 缂栬緫鍣紝涔熷簲璇ュ緢瀹规槗閬靛惊鐩稿悓鐨勮繃绋嬨

\documentclass[a4paper]{article}

\begin{document}

Hello World !  % This is your content

\end{document}

鍦 TexMaker 涓畬鎴愬悗鐨勭粨鏋滃簲璇ュ拰涓嬪浘涓鏍凤細

娣卞叆鐞嗚В Hello World

:eyes: 浠旂粏鐪嬩綘鐨勭涓涓 LaTeX 鏂囦欢浣犱細鍙戠幇锛

:zap: 娉ㄦ剰 :zap:

浣跨敤澶氱璇█

鏈変簺璇█涓嶈兘寮绠卞嵆鐢ㄣ備负浜嗗湪 TeX 涓娇鐢ㄥ叾浠栬瑷锛屼綘鏈夎繖浜涢夋嫨锛

:white_check_mark: 绗竴绉嶆柟娉 :white_check_mark:

绗竴绉嶆柟娉曟槸瀵煎叆鈥滃畯鍖(packages)鈥(浣犱細鍦ㄤ箣鍚庡鍒)銆傚洜涓洪粯璁ょ殑缂栬瘧鍣 pdfLaTeX 闄愬埗涓 256 涓瓧绗﹀苟涓旀湁寰堝缂栫爜闂銆備緥濡傦細

\documentclass[a4paper]{article}

\usepackage[T5]{fontenc}
\usepackage[utf8]{inputenc}

\begin{document}

Xin ch脿o th岷 gi峄沬. This is Hello World in Vietnamese.

\end{document}

杩欓噷鎴戜滑浣跨敤浜 usepackage[T5]{fontenc}usepackage[utf8]{inputenc} 瀹忓寘銆傝繖绉嶆柟娉曢潪甯稿鏄撶悊瑙o紝鐢ㄥ畯鍖呭皢瀛椾綋瀵煎叆瀛椾綋缂栫爜鍣ㄥ苟姝g‘鏄剧ず浣犵殑鍐呭銆傚鏋滀綘姝e湪浣跨敤 TexMaker 锛岄偅涔堜唬鐮佹樉绀虹殑缁撴灉灏嗕細濡備笅鍥炬墍绀猴細

瀵规瘮娌℃湁瀵煎叆瀹忓寘 :package: 鐨勬儏鍐碉細

:umbrella: 杩欐湁涓涓鐞嗕腑鏃ラ煩瀛楃鐨勫皬鎶宸э紝浣跨敤 usepackage{CJKutf8}\begin{CJK}{UTF8}\end{CJK} 闈炲父渚垮埄銆傝繖閲屾湁涓涓棩璇増鏈 :jp: :

\documentclass[a4paper]{article}
\usepackage{CJKutf8}

\begin{document}

\begin{CJK}{UTF8}{min}
銇撱伄瑷樹簨銈掕銈撱仹銇勩仧銇犮亶銇傘倞銇屻仺銇嗐仈銇栥亜銇俱仚銆
%Thank you for reading this article.
\end{CJK} 

\end{document}

灏卞儚鍚 :sushi: 鍜 :bento: 涓鏍风畝鍗:

:white_check_mark: 绗簩绉嶆柟娉 :white_check_mark:

鍙︿竴绉嶆柟娉曟槸鍒囨崲浣犵殑 TeX 缂栬瘧鍣ㄥ埌 LuaLaTeX (or XeLaTeX)銆備娇鐢 fontspecpolyglossia, 鐒跺悗浣犲氨鍙互鐩存帴浣跨敤 Unicode :

\documentclass[a4paper]{article}

\usepackage{fontspec}
\usepackage{polyglossia}
%\setmainfont[]{DejaVu Serif}

\begin{document}

Xin ch脿o th岷 gi峄沬. This is Hello World in Vietnamese.

\end{document}

榛樿瀛椾綋(Latin Modern)涓嶆敮鎸佸叏閮ㄥ瓧绗︼紝浣嗘槸浣犲彲浠ラ氳繃鍙栨秷 \setmainfont 琛岀殑娉ㄩ噴锛屼娇鐢ㄧ郴缁熶笂瀹夎鐨勭粷澶у鏁板瓧浣擄紙瀹屽叏鏀寔 TTF 鍜 OTF 瀛椾綋锛夈

鍒楄〃

:straight_ruler: 淇濇寔浣犵殑鏂囦欢缁撴瀯娓呮櫚鏄緢閲嶈鐨勶紝鍥犳锛岃鎴戜滑浠庨」鐩垪琛ㄥ紑濮嬪璧枫 涓や釜甯哥敤鐨勯」鐩垪琛ㄧ被鍨嬫槸鏈夊簭鏃犲簭鍒楄〃銆侺aTeX 鍙互杞绘澗鐨勫鐞嗕袱绉嶅垪琛細

浠ヤ笅鏄袱绉嶇被鍨嬪垪琛ㄧ殑杈撳嚭鏍峰紡锛

娈佃惤涓庣珷鑺

:blue_book: 鎴戜滑鐢 \section 琛ㄧず涓鑺傦紝鐢 \paragraph 琛ㄧず涓涓钀姐 :orange_book: 浣犺繕鍙互鐢 \subsection 娣诲姞灏忚妭锛岀敤 \subparagraph 娣诲姞灏忔钀姐

鎻掑叆鐩綍

:metal: 閫氳繃鎻掑叆 \tableofcontents 鍦ㄧ洰褰曚腑鏄剧ず鑺傚拰灏忚妭鏄潪甯告柟渚跨殑銆

渚嬪锛

:bangbang: 灏忔妧宸: 浣犲彲浠ヤ娇鐢 \newpage鍛戒护鏉ュ垱寤烘柊鐨勪竴椤点

鑴氭敞

浣跨敤鑴氭敞 + 鏍囩 + 鍙傝冩潵鍋氬悇绉嶅悇鏍风殑鑴氭敞锛屽氨鍍忓埗浣滈ゼ棣呬竴鏍风畝鍗曘備緥濡傦細

Hi let me introduce myself\footnote{\label{myfootnote}Hello footnote}.
... (later on)
I'm referring to myself \ref{myfootnote}.

:point_down: :point_down:浣犺兘鐪嬭瀹冨悧锛:point_down: :point_down:

:bangbang: 灏忔妧宸: 浣犲彲浠ヤ娇鐢 \newline 鏉ユ崲琛屻

浠涔堟槸瀹忓寘

LaTeX 榛樿鎻愪緵璁稿鍑芥暟锛屼絾鍦ㄦ煇浜涙儏鍐典笅锛屽畯鍖呭氨鍙互娲句笂鐢ㄥ満銆備綘鍙互浣跨敤 \usepackage :package: 鏉ュ鍏ュ畯鍖咃細

杩欐湁涓涓娇鐢ㄤ袱涓畯鍖呮潵鏄剧ず鏁板鍏紡鐨勪緥瀛:

瀹忓寘鐢氳嚦鍙互鐢ㄦ潵缁樺埗鐢佃矾鍥:

:construction: 濡傛灉浣犳湁鍏朵粬闇姹傦紝浣犲彲浠ョ敤璋锋瓕鎼滅储浣犻渶瑕佺殑瀹忓寘銆備緥濡: amsmath 鍚湁澶ч噺鏁板鏍煎紡鎷撳睍骞惰骞挎硾鐢ㄤ簬鏁板瀛︾锛宑ircuitikz 鐢ㄤ簬鐢佃矾璁捐绛夌瓑銆傘傘傝繖绡囬氱敤鐨勬寚鍗楁棤娉曞皢杩欎簺鐭ヨ瘑鍏ㄩ儴瑕嗙洊銆

琛ㄦ牸

涓涓疄鐢ㄧ殑渚嬪瓙:

\begin{table}[h!]
  \centering
  \caption{Caption for the table.}
  \label{tab:table1}
  \begin{tabular}{l|c||r}
    1 & 2 & 3\\
    \hline
    a & b & c\\
  \end{tabular}
\end{table}

:star2: 杩欐槸瀹冩覆鏌撳畬鐨勬牱寮 :star2: :

鐜板湪璁╂垜浠啀鍥為【涓涓 :eyes: :

:bangbang: 灏忔妧宸 浣犲彲浠ヤ娇鐢ㄤ竴涓悕鍙 booktabs 鐨勫畯鍖 :package: 鏉ヨ幏寰楁洿濂界殑瑙嗚鏁堟灉銆

娣诲姞鍥惧儚

鑻ユ兂鍦 LaTeX 鏂囦欢涓坊鍔犲浘鍍忥紝浣犻渶瑕佷娇鐢ㄥ浘褰㈢幆澧冨拰 graphicx 瀹忓寘銆備娇鐢 \usepackage{graphicx}

\begin{figure}
  \includegraphics[width=\linewidth]{filename.jpg}
  \caption{What is it about?}
  \label{fig:whateverlabel}
\end{figure}

:bangbang: 灏忔妧宸: 鐢 [width=\linewidth] 灏嗗浘鍍忕缉鏀惧埌鏂囨。鐨勫搴︺ 濡傛灉浣犳兂娴姩鍥惧儚锛岄偅涔堜綘闇瑕佺敤涓涓壒瀹氱殑鍊肩粰寮澶磋祴鍊笺俧ig 鐢ㄦ潵鍦ㄥ悗闈㈣寮曠敤锛屾墍浠ラ渶瑕佷粩缁嗗懡鍚嶃

\begin{figure}[h!]

:passport_control: 鍚堟硶鐨勫兼湁:

涓嬪浘鏄浘鍍忓憟鐜扮殑鏍峰紡:

鍦 LaTeX 涓彃鍏ヤ唬鐮

:white_check_mark: 绗竴绉嶆柟娉 :white_check_mark:

瀵圭▼搴忓憳鍜屽紑鍙戜汉鍛樿嚦鍏抽噸瑕佺殑涓涓柟闈㈡槸濡備綍涓撲笟鍦板皢浠g爜鎻掑叆鍒版枃妗d腑銆

鍦 LaTeX 涓,杩欎釜杩囩▼绠鍗曚笖涓撲笟锛屾垜浠彧闇浣跨敤涓浜涢瀹氫箟鐨勬爣璁版潵鍖呰9杩欎簺浠g爜锛岀劧鍚庡氨鍙互浜嗐

渚嬪:

\documentclass[a4paper]{article}

\begin{document}

Hello world!

\begin{verbatim}
#include <iostream>

int main()
{
	std::cout << "hello world!\n";
	return 0;
}
\end{verbatim}

\end{document}

:speech_balloon: LaTeX 鏀寔杩欎簺璇█鐨勮娉 :speech_balloon:

濡備綘鎵瑙侊紝閫氳繃浣跨敤 {verbatim} 鍖呰9锛屼綘鍙互杞绘澗鎻掑叆浠g爜鑰屼笉鐢ㄦ媴蹇冭娉曠殑鏍煎紡鍖栭棶棰樸備笅鍥炬槸瀹冩覆鏌撶殑缁撴灉锛屽共鍑銆佷笓涓氥佸紑绠卞嵆鐢:

:white_check_mark: :white_check_mark: 绗簩绉嶆柟娉 :white_check_mark: :white_check_mark:

杩欑鏂规硶璁╀綘鏈夋洿澶氱殑閫夋嫨锛屾瘮濡:鎻掑叆浠g爜鍐呰仈,浣跨敤鑷畾涔夋牱寮鐨勪唬鐮侊紝閫夋嫨鐗瑰畾浠g爜璇█,鍚屼竴鐩綍(the same directory)涓殑鍏朵粬鏂囦欢瀵煎叆浠g爜鈥︿娇鐢ㄨ繖涓柟娉曟椂锛屼綘鏃犻渶浣跨敤 {verbatim} 锛岃岄渶瑕佸寘鍚悕鍙 listings 鐨勫畯鍖 :package: 銆

鎬濊冧笅闈㈣繖涓牱渚嬶細

\documentclass[a4paper]{article}

\usepackage{listings}
\usepackage{color}

\lstdefinestyle{mystyle}{
keywordstyle=\color{magenta},
backgroundcolor=\color{yellow},
commentstyle=\color{green},
basicstyle=\footnotesize,
}
\lstset{style=mystyle}

\begin{document}


Hello world!

\begin{lstlisting}[language=Python]

print "Hello World!"

\end{lstlisting}

\lstinputlisting[language=C++]{hello.cpp}

Lorem ipsum dolor sit amet \lstinline{print "Hello World"} , consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


\end{document}

浠庤繖涓緥瀛愪腑锛屼綘浼氬彂鐜:

  1. 鎻掑叆鐨勪唬鐮佸潡锛屼粠 \begin{lstlisting} 寮濮嬶紝浠 \end{lstlisting} 缁撴潫銆
  2. 浣犲彲浠ヤ娇鐢 lstinputlisiting{name_of_file} 鏉ヤ粠鍚屼竴鐩綍(the same directory)涓嬪鍏ュ彟涓涓枃浠剁殑浠g爜銆
  3. [language=C++] 鏉ユ寚瀹氫娇鐢ㄧ殑璇█銆
  4. 鎯虫彃鍏ュ唴鑱斾唬鐮侀渶瑕佷娇鐢 \lstinline
  5. 鎯冲簲鐢ㄨ嚜瀹氫箟鏍峰紡锛岄渶瑕佷娇鐢 \usepackage{color} 鐒跺悗鐢ㄤ綘鑷繁鐨勪富棰樺畾涔夊垪琛(璇风湅涓嬮潰鐨勪唬鐮)銆備綘鍙互浣跨敤鑷繁鐨勯鏍间慨鏀硅澶氬唴瀹癸紝浣嗕綘闇瑕侀槄璇绘枃妗d互鑾峰彇姝g‘鐨勫睘鎬у悕绉般
  6. 鎰熷叴瓒o紵锛熸煡鐪鏇村鍐呭

浠ヤ笅鏄 TexMaker 涓殑浠g爜濡備綍缂栬瘧鐨:

鍒嗗壊涓哄涓 LaTeX 鏂囦欢

褰撴垜浠娇鐢 LaTeX 鏃讹紝鎴戜滑鍙兘鍥犱负涓涓枃妗eお闀胯屾棤娉曞鐞嗐傚洜姝わ紝鎴戜滑搴旇鍒嗗壊鏂囦欢锛屼娇鍏跺唴瀹瑰彲浠ヨ交鏉剧殑澶勭悊銆

璁╂垜浠湅杩欎釜渚嬪瓙:

% main.tex
\documentclass[a4paper]{article}

\begin{document}

Hello Latex, This is my first part.

Hello Latex, This is my second part.

\end{document}

杩欏彧鏄竴涓櫘閫氱殑 LaTeX 鏂囦欢锛岃鎴戜滑鐢 \input 鍏抽敭瀛楁潵灏嗘枃浠跺垎鎴愪袱涓儴鍒嗭細

% main.tex
\documentclass[a4paper]{article}

\begin{document}

Hello Latex, This is my first part.

\input{second_file}

\end{document}
% second_file.tex
Hello Latex, This is my second part.

鐜板湪锛屼富鏂囦欢鐪嬭捣鏉ユ湁浜涗笉鍚岋紝褰撴枃浠惰鏇村ソ鍦扮粍缁囦簡銆傚湪 TexMaker 涓殑缁撴灉濡備笅锛

multi_file.png

:bangbang: 灏忔妧宸 : 涓轰簡鍏锋湁鍙锛屾竻鏅帮紝渚夸簬缁存姢鐨勭洰鐨勶紝寮虹儓寤鸿浣犲皢涓绘枃浠剁郴缁熸х殑锛屽垎绾х殑锛岀瀛︾殑鍒嗗紑銆備笉瑕佹病鏈変换浣曠悊鐢辩殑鍒嗗紑锛屽惁鍒欎綘浼氬湪浠ュ悗鎰熷埌鍥版儜銆

鏇村宸ュ叿

鐗堟湰(Distributions)

LaTeX 缂栬緫鍣

LaTeX 缂栬瘧鍣

澶у鏁扮紪璇戝櫒鏈夐夐」鏉ユ敼鍙橀粯璁ょ紪璇戝櫒銆傝繖鏈変竴涓緥瀛:

鍝﹁ 锛侊紒

:tada: 鎭枩浣犲畬鎴愪簡鏈寚鍗椼傝繖鏄墍鏈変綘闇瑕佷簡瑙g殑鍏充簬 LaTeX 鐨勫熀鏈煡璇嗐 :hammer: 濡傛灉浣犳湁鍏磋叮浜嗚В鏇村鐨 LaTeX 鐭ヨ瘑锛岀偣鍑杩欓噷鎴栬呭彲浠ュ湪缃戜笂鎼滃浣犻渶瑕佺殑鍐呭銆

鐗堟潈璁稿彲

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Copyright (C) 2016 Luong Vo 姣忎釜浜洪兘琚厑璁镐慨鏀规垨鍒嗗彂鏈増鏉冩枃浠讹紝骞朵笖鍙鏇存敼鏂囦欢鍚嶏紝灏卞厑璁告洿鏀瑰畠(Changing it is allowed as long as the name is changed)銆傚鍒讹紝鍒嗗彂鍜屼慨鏀圭殑鏉℃鍜屾潯浠讹細浣犲彲浠ョ敤鏉ュ仛浠讳綍浣犳兂鍋氱殑銆

鎮ㄦ墍鍦ㄥ浗瀹朵拱涓鐡跺暏閰掓墍鑺辩殑閽卞彲浠ュ湪浣滆呴偅閲屼拱涓椤块キ銆