Skip to Main Content

Latex Workshop for RPGs

Introduce LaTex and Overleaf

Module 2 Demonstration Codes

\documentclass{article}
\usepackage[utf8]{inputenc}

%Put the following one command in preamble
\usepackage{amsmath}

\title{LaTex 2020 workshop making code}
\author{lbsamson.ust }
\date{November 2020}

\begin{document}

\maketitle

\section{About Maths}

% Inline mode – becomes part of your text
% delimiter choices:
%    \( ... \)
%    $ ... $ 
%    \begin{math} ... \end{math}
In physics, the mass-energy equivalence is stated by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.\\

% Display - put equation on separate line, delimiters choices:
% \[ ... \]
% \begin{displaymath} ... \end{displaymath}
% \begin{equation} ... \end{equation}
The mass-energy equivalence is described by the famous equation
\[ E=mc^2 \]
discovered in 1905 by Albert Einstein.
In natural units ($c = 1$), the formula expresses the identity
\begin{equation} %label is added at the end of the equation
E=m
\end{equation}\\

\end{document}
 

\documentclass{article}
\usepackage[utf8]{inputenc}

%Put the following one command in preamble
\usepackage{amsmath}

\title{LaTex 2020 workshop making code}
\author{lbsamson.ust }
\date{November 2020}

\begin{document}

\maketitle

\section{About Maths}

% Inline mode – becomes part of your text
% delimiter choices:
%    \( ... \)
%    $ ... $ 
%    \begin{math} ... \end{math}
In physics, the mass-energy equivalence is stated by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.\\

% Display - put equation on separate line, delimiters choices:
% \[ ... \]
% \begin{displaymath} ... \end{displaymath}
% \begin{equation} ... \end{equation}
The mass-energy equivalence is described by the famous equation
\[ E=mc^2 \]
discovered in 1905 by Albert Einstein.
In natural units ($c = 1$), the formula expresses the identity
\begin{equation} %label is added at the end of the equation
E=m
\end{equation}\\

\newpage
\section{Alignment and Sub equations}
The equation \ref{eqn:2} below shows how to create sub equations. 

\begin{subequations}    %sub equation environment 
\label{eqn:2}    %label the equation for \ref
\begin{align}        %algin environment
% use & to control align ment
&S_{ij} = A_{i}e_{i}P_{i}W^{\alpha}_j\exp{(-\beta{}{c_{ij}})}\\
%use nonubmer make this line without numbering
&where \nonumber\\    
&A_i = \sum_{k}W^{\alpha}_{k}\exp{(-\beta{}{c_{ik}})}\\
&to~ensure~that \nonumber\\
&\sum_{j}S_{ij} = e_{i}P_{i}
\end{align}
\end{subequations}

\end{document}
 

%Code for plotting graph

%Add pgfplots package in preamble
\begin{tikzpicture}
\begin{axis}
\addplot[color=green]{ln(x)};
\end{axis}
\end{tikzpicture}
%insert a horizontal blank gap
\hskip 5pt
%Here begins the 3d plot
\begin{tikzpicture}
\begin{axis}
\addplot3[    
surf,
]{x^3-y^3)*x};
\end{axis}
\end{tikzpicture}

© HKUST Library, The Hong Kong University of Science and Technology. All Rights Reserved.