Eyes, JAPAN Blog > Let’s start LaTeX

Let’s start LaTeX

zeng

この記事は1年以上前に書かれたもので、内容が古い可能性がありますのでご注意ください。

Are you still just use WORD to edit your reports? Have you ever been in a fret when editing a complex formula or page layout?  It’s time to introduce a new solution, Latex.

What is LaTeX?

  • LaTeX is a high-quality typesetting system, it includes features designed for the production of technical and scientific documentation.
  • LaTeX is the de facto standard for the communication and publication of scientific documents.
  • LaTeX is available as free software.

How to start it?

Firstly, you need a LaTeX platform. You can install TeXLive on your computer, so you can edit your reports without a network connection. TeX Live provides a comprehensive TeX system with binaries for most flavors of Unix, including GNU/Linux, macOS, and also Windows, all sources can be found here. However, I’d like to recommend an online platform, Overleaf. This blog will show a simple demo with Overleaf.

“Hello world” in Overleaf

\documentclass{helloWorld}

\begin{document} %This is the class document that defines most of the attributions.

First document, this is a simple demo with no extra parameters or packages included.

\end{document}

The instance will be:

The \documentclass{helloWorld} defines the type of document. You can find many great templates on the Internet.

Defining a title

\documentclass{helloWorld}

\section{A Demo of LaTex}

\begin{document}

First document, this is a simple demo with no extra parameters or packages included.

\end{document}

That will be:

The command \section{} marks the beginning of a new section, inside the braces is set the title. In this way, \subsection{}, subsubsection{} can present subheads. You can write the content under this section.

Inserting an Image

\documentclass{helloWorld}

\usepackage{graphicx}

\begin{document}

First document, this is a simple demo with no extra parameters or packages included.

\begin{figure}[!h]
\centering
\includegraphics[width=0.4\textwidth]{images/292a174fde75614e2ec9f0e02c7c7077.jpeg}
\caption{Panda}
\label{fig: panda}
\end{figure}

This guy is a ferocious and dangerous beast like a tiger and a lion.

\end{document}

The instance will be:

!h is used to insert the image here. you can use !t or !b to put the image on the top  or bottom of the page. the command  \centering is to center the image. In command \includegraphics[]{}, the size of image can be defined with \includegraphics[width=0.2, heigh=0.5]{the path of the image in this project folder} or \includegraphics[scale=0.5]{the path of the image in this project folder}. the command \caption{} can add the name of the image. \label{} is very convenient for the editor to quote the image because LaTex can assign the number of the image automatically.

If you want to show two images side by side, you need to add the package \usepackage{subfigure}.

\begin{figure}[h!]
\centering
\subfigure[Tiger]{
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[scale=0.52]{picture/1603844651(1).jpg}
\end{minipage}}%
\subfigure[Panda]{
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[scale=0.3]{picture/292a174fde75614e2ec9f0e02c7c7077.jpeg}
\end{minipage}}%
\end{figure}

The instance is like:

The command \begin{minipage}[t]{0.5\linewidth} means the image will occupy the width of the page.

Making a Table

\begin{table}[!h]
\centering
\caption{The transcript}
\label{tab:my-table}
\begin{tabular}{|l|l|l|l|l|}
\hline
Name & Mathmatic & Physical & Chemistry & Average \\ \hline
Marke & 70 & 90 & 65 & 75 \\ \hline
John & 88 & 75 & 86 & 83 \\ \hline
\end{tabular}
\end{table}

or maybe you use other type of borders like:

That requests to change \begin{tabular}{|l|l|l|l|l|} to \begin{tabular}{ l l l l l }. the symbol & changes the collown, the command \\hline starts a new row.

Editing formulas like writing a sentence

\documentclass{helloWorld}

\begin{document}

First document, this is a simple demo with no extra parameters or packages included.

\begin{equation}

E=mc^2

\end{equation}

\end{document}

The instance will be:

This demo shows a few things about LaTex. Mass tutorials are accessible on the website of Overleaf and Youtube for free.

Comments are closed.