Skip to content

Instantly share code, notes, and snippets.

@vivngo
Created March 1, 2018 22:57
Show Gist options
  • Save vivngo/e37e1c7b79bf7e8b910c6566c59c46be to your computer and use it in GitHub Desktop.
Save vivngo/e37e1c7b79bf7e8b910c6566c59c46be to your computer and use it in GitHub Desktop.
SQL syntax highlighting in LaTeX
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{language=SQL,
basicstyle={\small\ttfamily},
belowskip=3mm,
breakatwhitespace=true,
breaklines=true,
classoffset=0,
columns=flexible,
commentstyle=\color{dkgreen},
framexleftmargin=0.25em,
frameshape={}{yy}{}{}, %To remove to vertical lines on left, set `frameshape={}{}{}{}`
keywordstyle=\color{blue},
numbers=none, %If you want line numbers, set `numbers=left`
numberstyle=\tiny\color{gray},
showstringspaces=false,
stringstyle=\color{mauve},
tabsize=3,
xleftmargin =1em
}
@playerEric1
Copy link

Thank you! It works perfectly!

@vivngo
Copy link
Author

vivngo commented Feb 1, 2023

@playerEric1 Haha I forgot about this! I'm glad. Your comment made my day :-)

@mcarlosfr
Copy link

Nice thank you, It got me into doing the same for Python too, thank you.

@vivngo
Copy link
Author

vivngo commented Jun 7, 2023

@mcarlosfr So glad to hear that! Best of luck on your project :-)

@egeorg02
Copy link

How can this be used? I'm new in LaTeX and I'm trying to include an SQL query in a document

@I-Am-Bernd
Copy link

@egeorg02 You put your SQL Code in a block like this
\begin{lstlisting}
SQL-Code
\end{lstlisting}
(If you haven't found out yourself by now :D)

Many thanks to the author, worked perfectly well!

@abutoameh
Copy link

Thanks you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment