Catatan LaTeX

Sekadar berbagi catatan LaTeX.

LaTeX itu apa sih?

LaTeX (Lamport TeX) is a word processor and a document markup language. It is distinguished from typical word processors such as Microsoft Word and Apple Pages in that the writer uses plain text as opposed to formatted text, relying on markup tagging conventions to define the general structure of a document (such as article, book, and letter), to stylise text throughout a document (such as bold and italic), and to add citations and cross-referencing. A TeX distribution such as TeXlive or MikTeX is used to produce an output file (such as PDF or DVI) suitable for printing or digital distribution. Wikipedia

Basic structure

Struktur dasar dokumen LaTeX:

\documentclass{}
... % preamble area
\begin{document}
... % content area
\end{document}

Bagian antara \documentclass{} dan \begin{document} disebut preamble, yaitu tempat kita mendefinisikan \documentclass{}, perintah \usepackage{}, serta mengatur semua setting terkait dokumen LaTeX tersebut (misal: jarak margin, ukuran halaman, jenis font, dsb). Sedangkan bagian antara \begin{document} dan \end{document} adalah tempat kita menulis konten yang sebenarnya.

LaTeX punya banyak documentclass, tapi yang paling sering dipakai adalah article. Soal ini sebaiknya kita bahas di bagian lain.

Basic usage and compiling

Sekarang mari kita coba buat file LaTeX pertama. Dalam contoh kali ini (dan contoh-contoh berikutnya) kita akan menggunakan \documentclass{article}.

\documentclass{article}
\begin{document}
Belajar LaTeX.
\end{document}

Simpan dengan nama basic-01.tex. (PS: file LaTeX selalu berakhiran dengan .tex). Untuk melihat hasilnya, kita mesti meng-compile dokumen tersebut untuk menghasilkan file PDF. Lihat hasilnya.

Oiya, ada dua cara untuk meng-compile dokumen. Pertama, melalui linux terminal. Caranya: buka terminal (tekan Ctrl+Alt+T), lalu ketik pdflatex namafile. Kedua, melalui (La)TeX editor. Caranya: klik tombol Run atau Compile. Soal LaTeX editor akan kita bahas dalam bagian lain.

Text formatting

Perintah:

\textbf{} → bold
\emph{} → italic

Contoh:

\documentclass{article}
\begin{document}
Teks biasa. Yang ini \textbf{bold}. Kalau ini \emph{italic}.
\end{document}

Lihat hasilnya.

Paragraph alignment

Default

Paragraph dalam LaTeX otomatis dibuat rata kanan-kiri (justified) dan indent/menjorok seperti ini.

\documentclass{article}
\begin{document}
Paragraph dalam LaTeX otomatis dibuat rata kanan-kiri (justified) dan indent/menjorok seperti ini. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
Default-paragraph alignment
Default-paragraph alignment

Untuk memulai paragraph baru, tekan tombol ENTER dua kali, seperti ini.

\documentclass{article}
\begin{document}
Paragraph dalam LaTeX otomatis dibuat rata kanan-kiri (justified) dan indent/menjorok seperti ini. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Untuk memulai paragraph baru, tekan tombol ENTER dua kali, seperti ini. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
Dua paragraph
Dua paragraph

Left aligned

Format:

\begin{flushleft}
... % tulis paragraph di sini.
\end{flushleft}

Contoh:

\documentclass{article}
\begin{document}
\begin{flushleft}
Paragraph rata kiri (left-aligned). Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{flushleft}
\end{document}
Left-aligned
Left-aligned

Right aligned

Format:

\begin{flushright}
... % tulis paragraph di sini.
\end{flushright}

Contoh:

\documentclass{article}
\begin{document}
\begin{flushright}
Paragraph rata kanan (right-aligned). Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{flushright}
\end{document}
Right-aligned
Right-aligned

Centered

Format:

\begin{center}
... % tulis paragraph di sini.
\end{center}

Contoh:

\documentclass{article}
\begin{document}
\begin{center}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{center}
\end{document}
Centered
Centered

Bullet and numbering list

Bullet list

Format:

\begin{itemize}
\item item list % list item
\end{itemize}

Contoh:

\documentclass{article}
\begin{document}
\begin{itemize}
\item satu
\item dua
\item tiga, dst.
\end{itemize}
\end{document}

Kalau masing-masing item berupa satu kalimat/paragraph, bisa juga ditulis seperti ini:

\documentclass{article}
\begin{document}
\begin{itemize}
\item satu \item dua \item tiga, dst.
\end{itemize}
\end{document}

Bullet list juga bisa dibuat berjenjang.

Contoh:

\documentclass{article}
\begin{document}
\begin{itemize}
\item satu
\item dua
	\begin{itemize}
		\item dua satu
		\item dua dua
		\item dua tiga
	\end{itemize}
\item tiga, dst.
\end{itemize}
\end{document}

Nested bullet list
Nested bullet list

Number list

Mirip dengan itemize. Ganti itemize menjadi enumerate.

Format:

\begin{enumerate}
\item item list % list item
\end{enumerate}

Contoh:

\documentclass{article}
\begin{document}
\begin{enumerate}
\item satu
\item dua
\item tiga, dst.
\end{enumerate}
\end{document}

Numbering list juga bisa dibuat berjenjang.

Contoh:

\documentclass{article}
\begin{document}
\begin{enumerate}
\item satu
\item dua
	\begin{enumerate}
		\item dua satu
		\item dua dua
		\item dua tiga
	\end{enumerate}
\item tiga, dst.
\end{enumerate}
\end{document}
Nested number list
Nested number list

[..bersambung…]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s