LaTeX code files, was written in my learning process.
LaTeX is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents but it can be used for almost any from of publishing.
LaTeX encourages authors not to worry too much about the apprearance of their documents but not concertrante on getting the right content.
What it is, not How it looks.
- Small files.
- Cross-platform compatibility
- Easy to make templates.
- Free.
- You write your document in plain text with commands that describe its structure and meaning.
- The latex program processes your text and commands to produce a beautifully formatted document.
- Compiler
- Gnu/Linux (TexLive)
- Mac (MacTex)
- Windows (MIKTeX)
- Editor
- TeXstudio, Texmaker, ...
- Or use web-based Online Editors
-
Typesetting
- comment:
% this is comment
- new line:
\\
- spaces:
\quad
or\qquad
- print %, {, ...and more:
\%
,\{
, ... (use anti-slash before special character) - bold:
\textbf{value}
- italic:
\textit{value}
- underline:
\underline{value}
- 3 dots:
\dots
- Link:
\href{url}{description}
- comment:
-
Math
- inline math mode:
$ value $
- symbols:
\alpha
,\beta
,\omega
, ... - sub-script:
X_2
- sup-script:
X^2
- multi sub or sup script:
x^{2x + 3}
orx_{2x + 3}
(use brackets) - merge between sub and sup script:
\sum_{k=1}^n
- fractional:
d=\frac{5x}{y}
- equation
\begin{equation} \omega = \sum_{i=1}^{n}w_ix % content of equation \end{equation}
- label in equation
\begin{equation} \label{omega eq} % name of equation used to refered \omega = \sum_{i=1}^{n}w_ix \end{equation} \ref{omega eq}
- inline math mode:
-
Lists
- unordered list
\begin{itemize} % Unordered list \item Stackoverflow \item GitHub \end{itemize}
- unordered list
\begin{itemize} % Unordered list \item Stackoverflow \item GitHub \end{itemize}
- ordered list
\begin{enumerate} % Ordered list \item HTML \item CSS \end{enumerate}
- merge and list inside list
\begin{enumerate} % list inside list \item HTML \begin{enumerate} \item HTML4 \item HTML5 \end{enumerate} \item CSS \item PHP \item JS framework \begin{itemize} \item Angular \item React \item Vue \end{itemize} \end{enumerate}
-
Sections
\section{Introduction} \label{intro section} This is the first section \section{Problematic} This section based on section \ref{intro section} \subsection{Problem of access} Just simple Text \subsubsection{Title here}
-
Multi columns page
\documentclass[twocolumn]{article}
-
Packages
\documentclass{article} \usepackage{package_name} % add package \begin{document} Hello! \end{document}
-
Package > amsmath
\documentclass{article} \usepackage{amsmath} % use package (LaTeX will install package if not exist in your computer) \begin{document} \begin{equation*} % *: don't add number of equation \sum \end{equation*} \begin{align*} % align equation.. (X+1)^3&=(X+1)(X+1)(X+1)\\ &=(X+1)(X^2 + 2X + 1)\\ &=X^3+3X^2+3X+1 \end{align*} \end{document} \begin{equation} % for add single number of equation \begin{align*} (X+1)^3&=(X+1)(X+1)(X+1)\\ &=(X+1)(X^2 + 2X + 1)\\ &=X^3+3X^2+3X+1 \end{align*} \end{equation}
-
Pictures
- simple picture
\documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure} \includegraphics{img_url} \end{figure} \end{document}
- center
\begin{figure} \centering % make image in the center \includegraphics{images/Blue.png} \end{figure}
- position
\begin{figure}[!t] % make image in the (t:top, b:bottom, h:here, !:force[optional]) \includegraphics{images/Blue.png} \end{figure}
- width
\begin{figure} % change image width: 0.5\textwidth = 50% of the text width, 0.9\columnwidth = 90% of the column width \includegraphics[width=0.5\textwidth]{images/Blue.png} \end{figure}
- caption
\begin{figure} \caption{value} % name of photo (caption) \includegraphics{images/Blue.png} \end{figure}
- label
mentioned in Fig. \ref{img_ref} \begin{figure} \caption{\label{img_ref}value} \includegraphics{images/Blue.png} \end{figure}
- picture path
\graphicspath{{images/}} % pictures path (folder) \begin{document}
- subfigures
\usepackage{graphicx} \usepackage{caption} \usepackage{subcaption} \begin{document} \begin{figure*} % figure take all page with (in case we use twocolumn) \centering \begin{subfigure}[b]{0.45\columnwidth} \includegraphics[width=\textwidth]{images/Red.png} \caption{} \label{fig:red_logo} \end{subfigure} ~ % ~: beside, <new line (blank)>: bottom to \begin{subfigure}[b]{0.45\columnwidth} \includegraphics[width=\textwidth]{images/Blue.png} \caption{} \label{fig:blue_logo} \end{subfigure} \caption{(a) Logo Red. (b) Logo Blue.} \label{fig:app_logo} \end{figure*} \end{document}
-
Tables
\usepackage{tabularx}
\begin{document}
\begin{table}[!h]
\begin{tabular}{|l|c|r|} % alignment of columns (l: left, r: right, c: center), |: columns separator (vertical ligne)
\hline % make ligne (separator)
Item & Qty & Unit \\ % row one
\hline
Widget & 1 & 199.99 \\
\hline
Gadget & 2 & 399.99 \\
\hline
\end{tabular}
\end{table}
\end{document}