DEV Community

Siva
Siva

Posted on • Originally published at Medium on

Mastering LaTeX Formatting: A Guide with Examples

Introduction:

LaTeX is a powerful tool for document preparation, but mastering its formatting capabilities can be a challenge. In this guide, I’ll walk you through some of the essential LaTeX formatting techniques, complete with examples that you can try out for yourself.

Section 1: Basic Formatting Techniques

  • Bold and Italic Text: Use \textbf{} for bold and \textit{} for italicized text. Example: This is \textbf{bold} and this is \textit{italicized} text.
  • Underlined Text: Use \underline{}. Example: This is \underline{underlined} text.
  • Superscript and Subscript: Use ^{}for superscripts and _{} for subscripts. Example: H\textsubscript{2}O and E = mc\textsuperscript{2}.
  • Font Size: Use \fontsize{}{} for custom font sizes. Example: This text is {\fontsize{16}{18}\selectfont larger}than this text.
  • Bullet Points: Use \begin{itemize}and \itemfor bullet points. Example:
\begin{itemize} \item First item \item Second item \item Third item \end{itemize}
Enter fullscreen mode Exit fullscreen mode

Section 2: Advanced Formatting Techniques

  • Tables: Use the tabular environment for tables. Example:
\begin{tabular}{|c|c|} \hline Column 1 & Column 2 \ \hline Row 1, Column 1 & Row 1, Column 2 \ \hline Row 2, Column 1 & Row 2, Column 2 \ \hline \end{tabular}
Enter fullscreen mode Exit fullscreen mode
  • Figures: Use the graphicx package for figures. Example:
\begin{figure}[h] \centering \includegraphics[width=0.5\textwidth]{example-image} \caption{This is a caption for the figure.} \label{fig:example} \end{figure}
Enter fullscreen mode Exit fullscreen mode
  • Equations: Use the equation environment for equations. Example:
\begin{equation} E=mc\textsuperscript{2} \end{equation}
Enter fullscreen mode Exit fullscreen mode
  • References: Use \cite{} for references. Example: According to \cite{example}, LaTeX is a powerful tool for document preparation.

Conclusion:

With these LaTeX formatting techniques and examples, you can create professional-looking documents with ease. Whether you’re a student, researcher, or professional, LaTeX can help you take your documents to the next level.

Sample Latex Code

\documentclass[a4paper,12pt]{article}
\usepackage[left=2cm,right=2cm,top=1.5cm,bottom=2cm]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{itemize} \item First item \item Second item \item Third item \end{itemize}

\thinspace

\begin{tabular}{|c|c|} \hline Column 1 & Column 2 \\ \hline Row 1, Column 1 & Row 1, Column 2 \\ \hline Row 2, Column 1 & Row 2, Column 2 \\ \hline \end{tabular}

\begin{equation} E=mc\textsuperscript{2} \end{equation}

\end{document}
Enter fullscreen mode Exit fullscreen mode

Output

Sample PDF Preview

Extra’s

Here are the steps to install LaTeX:

  1. Visit the following link: https://tug.org/texlive/
  2. Click on the “Download” button on the top-right corner of the page.
  3. Choose the appropriate operating system and follow the instructions to download the installer.
  4. Once the installer is downloaded, run it and follow the instructions to install LaTeX.
  5. During the installation process, you will be prompted to select packages to install. You can choose to install the complete set of packages or only the packages you need.
  6. Once the installation is complete, you can start using LaTeX to create your documents.

Note: The installation steps may vary depending on the operating system you are using.

Top comments (0)