Introduction to Research Methodology
Lab 4: Introduction to LATEX for Civil Engineering Students
Prof M. R. Senouci
September 17, 2023
1 What is LaTeX? • Distribution: Choose and install a distribution
such as TeX Live (for Windows, macOS, and
LaTeX is a powerful typesetting system commonly Linux) or MiKTeX (for Windows).
used for creating high-quality, professional docu-
- TeX Live: https://www.tug.org/texlive/
ments in the field of civil engineering and other tech-
nical disciplines. It offers precise control over docu- - MiKTeX: https://miktex.org/
ment formatting and is particularly suited for tech-
• Editor: Select a LaTeX editor like TeXmaker,
nical reports, research papers, theses, and more.
TeXstudio, TeXworks, or use an online editor like
Overleaf.
1.1 Why Use LaTeX in Civil Engi-
neering?
3 LaTeX Basics
• Precision: LaTeX allows you to create documents
with precise formatting, making it ideal for techni- 3.1 Document Structure
cal reports, equations, and diagrams.
A basic LaTeX document structure includes:
• Efficiency: LaTeX automates many formatting
tasks, saving you time and effort when creating \documentclass{article} % Document class declaration
complex documents. \begin{document} % Document begins here
...
• Mathematics: It excels at typesetting mathemat- \end{document} % Document ends here
ical equations and symbols commonly used in en-
gineering. 3.2 Sections and Subsections
• Collaboration: LaTeX supports collaborative Organize your document into sections and subsec-
writing, making it suitable for group projects and tions:
research papers.
\section{Introduction}
This is the introduction section.
2 Getting Started with LaTeX \subsection{Background}
This is a subsection under the introduction.
2.1 Installation
3.3 Text Formatting
Before using LaTeX, you need to install a LaTeX dis-
tribution and a LaTeX editor. Use LaTeX commands for text formatting:
1
• Bold: \textbf{Bold text} 3.5 Packages
• Italic: \textit{Italic text} LaTeX is highly extensible, and one of its strengths
lies in its vast collection of packages. Packages
• Underline: \underline{Underlined text}
are sets of macros and commands that extend La-
TeX’s functionality, allowing you to accomplish spe-
3.4 Lists cific tasks or formatting requirements.
Create ordered and unordered lists: To use a package, include it in the pream-
ble of your LaTeX document using the
\begin{itemize} % Unordered list \usepackage{package-name} command:
\item Item 1
\item Item 2 \usepackage{graphicx} % To include graphics
\end{itemize}
3.6 Tables
\begin{enumerate} % Ordered list
Design tables with LaTeX:
\item First item
\item Second item \begin{table}[ht]
\end{enumerate} \centering
You can customize labels for ordered and un- \caption{Basic Table}
ordered lists. For unordered lists, use the \begin{tabular}{|c|c|}
\item[custom-label] command: \hline
Column 1 & Column 2 \\
\begin{itemize} \hline
\item[$\star$] Item 1 Data 1 & Data 2 \\
\item[$\diamond$] Item 2 \hline
\item[$\circ$] Item 3 \end{tabular}
\end{itemize} \end{table}
For ordered lists, use the command
\begin{enumerate}[label=custom-label]: The booktabs package offers enhanced table format-
ting:
\begin{enumerate}[label=(\alph*)]
\item Item 1 \usepackage{booktabs}
\item Item 2 ...
\item Item 3 \begin{tabular}{lc}
\end{enumerate} \toprule
Header 1 & Header 2 \\
You can nest lists within other lists to create hi-
\midrule
erarchical structures. Here’s an example of a nested
Data 1 & Data 2 \\
list:
Data 3 & Data 4 \\
\begin{itemize} \bottomrule
\item Main Item \end{tabular}
\begin{itemize}
\item Subitem 1
\end{itemize}
3.7 Figures
\item Another Main Item
\end{itemize} Insert figures into your LaTeX document using the
graphicx package:
2
R∞
\begin{figure} • Integrals: 0
f (x)dx
\centering $\int_{0}^{\infty} f(x) dx$
\includegraphics[width=5cm]{figure.png}
\caption{Caption for the figure.} 1 2
• Matrices:
\label{fig:figure-label} 3 4
\end{figure}
$\begin{bmatrix}
1 & 2 \\
4 Mathematical Equations and 3 & 4 \\
\end{bmatrix}$
Symbols
LaTeX excels at typesetting mathematical content, 4.4 Subscripts and Superscripts
making it an invaluable tool for engineering and sci-
Use underscores (_) for subscripts and caret symbols
entific documents. In this section, we’ll explore how
(^) for superscripts: Temperature (T0 ) and pressure
to create and format mathematical equations and
(P ∗ ) are important variables.
symbols in your LaTeX document.
4.5 Equation Alignment
4.1 Inline Mathematics
For multiple equations, use environments like align
To include mathematical content within your text,
or align* to align equations at a specific character,
enclose it between dollar signs ($). For example:
such as the equal sign:
The Pythagorean theorem, $a^2 + b^2 = c^2$, x=y+z (1)
is fundamental in geometry.
a=b−c (2)
4.2 Displayed Equations \begin{align}
x &= y + z \\
For more complex equations that deserve their own a &= b - c
line, use double dollar signs ($$) or the \[ and \] \end{align}
delimiters:
The equation for the area of a circle
is given by:
5 Cross-References in LaTeX
\[A = \pi r^2\] Cross-referencing allows you to create links within
your document to refer to sections, figures, tables,
4.3 Mathematical Symbols equations, or any labeled element. To create a cross-
reference, follow these steps:
LaTeX provides a vast array of mathematical sym-
bols. Here are a few common examples: 1. Label the Element: First, label the element you
want to reference. For example, to label a sec-
• Greek letters: α, β, γ tion, place \label{sec:my-section} after the
$\alpha$, $\beta$, $\gamma$ section title.
• Fractions: 1
$\frac{1}{2}$
2 2. Reference the Element: In your text, use
√ \ref{label} or \pageref{label} to reference
• Square root: x $\sqrt{x}$
Pn the labeled element. Replace ‘label‘ with the la-
• Summation: i=1 xi $\sum_{i=1}^{n} x_i$ bel you assigned earlier.
3
Here’s an example: Suppose you 5. Compile with BibTeX: Compile your LaTeX doc-
have a section labeled as follows: ument with BibTeX. This generates the bibliog-
\section{Introduction}\label{sec:intro}. raphy based on your citations.
To reference this section elsewhere in your
document: In Section~\ref{sec:intro} or 6. Compile Twice: Compile your document twice
\autoref{sec:intro}, we discuss the introduction. to ensure all references are properly updated.
This will automatically generate a link to the
Here’s an example of a BibTeX entry for a journal
labeled section, such as ”In Section 1, we discuss the
article:
introduction,” where ”Section 1” is a clickable link
to the section. You can also reference figures, tables, @article{smith2019,
equations, or any other labeled element in a similar author = {John Smith},
manner. title = {A Comprehensive Study of Civil Engineering},
As shown in Figure~\ref{fig:data-plot}, ... journal = {Journal of Civil Engineering},
year = {2019},
To ensure cross-references are correctly resolved, volume = {42},
you may need to compile your document multiple number = {3},
times. pages = {123-135},
doi = {10.1234/jce.2019.42.3.123}}
6 Bibliography Management
7 Troubleshooting
In academic and research writing, it’s essential to
cite sources properly. LaTeX simplifies this process When facing issues with LaTeX, consider common
through its built-in bibliography management sys- troubleshooting tips like checking your code for errors
tem. To manage bibliographies in LaTeX, follow and recompiling your document. Error messages dur-
these steps: ing compilation often provide helpful clues. Online
communities such as TeX Stack Exchange and LaTeX
1. Create a BibTeX File: Create a separate ‘.bib‘ Community are valuable for seeking assistance and
file that contains the bibliographic information solutions. Additionally, consult LaTeX documenta-
of your sources. Each entry should have a unique tion, and don’t hesitate to ask for help when needed
citation key. as you navigate the learning curve.
2. Cite Sources: In your LaTeX document, use
\cite{citation-key} to cite a source. Replace 8 Additional Resources
‘citation-key‘ with the key from your ‘.bib‘ file.
• The LaTeX Project: https://www.
3. Choose a Bibliography Style: Spec- latex-project.org/
ify the desired bibliography style using
\bibliographystyle{style}. Common • LaTeX WikiBook: https://en.wikibooks.org/
styles include ‘plain‘, ‘unsrt‘, and ‘apalike‘. wiki/LaTeX
4. Generate the Bibliography: Place • Overleaf LaTeX Guide: https://www.overleaf.
\bibliography{your-bibliography-file} com/learn/latex/Main_Page
where you want the bibliography to appear in
your document. Replace ‘your-bibliography-file‘
with the name of your ‘.bib‘ file (without the
extension).