Skip to content

Instantly share code, notes, and snippets.

@Chubek
Created September 1, 2025 21:45
Show Gist options
  • Select an option

  • Save Chubek/763f5c66893665572f22126f833d0b4f to your computer and use it in GitHub Desktop.

Select an option

Save Chubek/763f5c66893665572f22126f833d0b4f to your computer and use it in GitHub Desktop.
LaTeX demo
\documentclass[12pt,a4paper]{article}
% --- Packages for General Utilities ---
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{lipsum} % filler text
\usepackage{microtype} % better typography
% --- Page and Graphics ---
\usepackage{geometry}
\geometry{margin=1in}
\usepackage{graphicx}
\usepackage{float}
\usepackage{xcolor}
% --- Hyperlinks ---
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
citecolor=red,
urlcolor=magenta
}
% --- Math ---
\usepackage{amsmath,amssymb,amsthm}
\usepackage{mathtools}
% --- Tables ---
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{array}
% --- Code Listings ---
\usepackage{listings}
\lstset{
basicstyle=\ttfamily\small,
backgroundcolor=\color{gray!10},
frame=single,
numbers=left,
numberstyle=\tiny,
keywordstyle=\color{blue},
stringstyle=\color{red!60!black},
commentstyle=\color{green!50!black}
}
% --- TikZ and PGFPlots ---
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
% --- Algorithm ---
\usepackage{algorithm}
\usepackage{algpseudocode}
% --- Bibliography ---
\usepackage{cite}
% --- Theorem-like environments ---
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
% Document
\title{\textbf{A Demonstration of \LaTeX\ Capabilities}}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\newpage
\section{Introduction}
\LaTeX\ is not just about math. It's about beautiful documents. Let's tour the features.
\section{Mathematics}
An inline equation: $E = mc^2$, and a displayed one:
\[
\int_{-\infty}^\infty e^{-x^2} \, dx = \sqrt{\pi}
\]
Numbered equations with labels:
\begin{equation}
a^n + b^n \neq c^n \quad \text{for } n>2
\label{eq:fermat}
\end{equation}
We refer to Equation~\ref{eq:fermat} later.
\section{Theorems and Proofs}
\begin{theorem}[Pythagoras]
In a right-angled triangle:
\[
a^2 + b^2 = c^2
\]
\end{theorem}
\begin{proof}
Apply Euclidean geometry. \qedhere
\end{proof}
\section{Tables}
\begin{table}[H]
\centering
\caption{An Example Table}
\begin{tabular}{l c r}
\toprule
Left & Center & Right \\
\midrule
1 & 2 & 3 \\
4 & 5 & 6 \\
\bottomrule
\end{tabular}
\end{table}
\section{Figures}
\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{example-image}
\caption{A sample image (placeholder)}
\end{figure}
\section{Code Listings}
\begin{lstlisting}[language=C, caption=Hello World in C]
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}
\end{lstlisting}
\section{Algorithms}
\begin{algorithm}[H]
\caption{Euclidean GCD Algorithm}
\begin{algorithmic}[1]
\Function{GCD}{a,b}
\While{$b \neq 0$}
\State temp $\gets$ b
\State b $\gets$ a \% b
\State a $\gets$ temp
\EndWhile
\State \Return a
\EndFunction
\end{algorithmic}
\end{algorithm}
\section{TikZ Diagram}
\begin{tikzpicture}[node distance=2cm, every node/.style={draw, rounded corners}]
\node (start) {Start};
\node (proc1) [below of=start] {Process 1};
\node (dec) [below of=proc1, diamond, aspect=2] {Decision?};
\node (proc2) [right of=dec, xshift=5cm] {Process 2};
\node (stop) [below of=dec, yshift=-4cm] {Stop};
\draw[->] (start) -- (proc1);
\draw[->] (proc1) -- (dec);
\draw[->] (dec.east) -- ++(2,0) -- (proc2.west);
\draw[->] (dec.south) -- ++(0,-2) -- (stop.north);
\end{tikzpicture}
\section{PGFPlots Example}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$, ylabel={$f(x)$},
title={A Sample Plot},
grid=major
]
\addplot[domain=-2:2,samples=100,blue]{x^2};
\addlegendentry{$x^2$}
\end{axis}
\end{tikzpicture}
\section{Citations}
Referencing \LaTeX\ \cite{lamport1994latex}.
\section{Conclusion}
\lipsum[2]
\bibliographystyle{plain}
\begin{thebibliography}{1}
\bibitem{lamport1994latex}
Leslie Lamport.
\newblock {\em \LaTeX: A Document Preparation System}.
\newblock Addison-Wesley, 2nd edition, 1994.
\end{thebibliography}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment