Skip to content

Instantly share code, notes, and snippets.

@kuang-da
Last active November 26, 2021 19:13
Show Gist options
  • Save kuang-da/6b070179fed847f80395cdf26ad1eb48 to your computer and use it in GitHub Desktop.
Save kuang-da/6b070179fed847f80395cdf26ad1eb48 to your computer and use it in GitHub Desktop.
[Notes about LaTeX] Examples and common code snipets of LaTeX #LaTeX
% ---------Introduction ----------------
% This snept is used to organize some small examples for LaTeX package listings.
% Iistings is a greate package for formating code in PDF files.
% https://ctan.org/pkg/listings?lang=en
% -------------------------------------
\usepackage{listings}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Code Style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\lstset{
numbers=left,
numberstyle=\small,
numbersep=8pt,
frame = single,
framexleftmargin=15pt,
breaklines=true,
columns=fullflexible
}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Inline code
%%%%%%%%%%%%%%%%%%%%%%%%%
\lstinline$var i:integer;$
%%%%%%%%%%%%%%%%%%%%%%%%%
% Code File
%%%%%%%%%%%%%%%%%%%%%%%%%
\lstinputlisting{my-code.py}
\lstinputlisting[language=Python]{my-code.py}
\lstinputlisting[language=R]{code/hw3-q2.R}
\lstinputlisting[language=Octave,
caption=Octave sample code
]{BitXorMatrix.m}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Code snippet
%%%%%%%%%%%%%%%%%%%%%%%%%
% Set line number
\lstset{numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt}
\begin{lstlisting}
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(`Case insensitive ');
WritE(`Pascal keywords.');
\end{lstlisting}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Floating code snippet
%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{lstlisting}[float,caption=A floating example,label=myLabel]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write(`Case insensitive');
WritE(`Pascal keywords.');
\end{lstlisting}
%%%%%%%%%%%%%%%%%%%%%%%%%
% Learn More
%%%%%%%%%%%%%%%%%%%%%%%%%
https://www.overleaf.com/learn/latex/code_listing
http://texdoc.net/texmf-dist/doc/latex/listings/listings.pdf
\begin{figure}[H]
\centering
\includegraphics[width=0.7\linewidth]{fig/screenshot001}
\caption{Conditional Contingency Table}
\label{fig:screenshot001}
\end{figure}
\documentclass{article}
\usepackage{physics}
\begin{document}
\[
\dv{Q}{t} = \dv{s}{t} \quad
\dv[n]{Q}{t} = \dv[n]{s}{t} \quad
\pdv{Q}{t} = \pdv{s}{t} \quad
\pdv[n]{Q}{t} = \pdv[n]{s}{t} \quad
\pdv{Q}{x}{t} = \pdv{s}{x}{t} \quad
\]
\[
\fdv{F}{g}
\]
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment