# How to insert StackExchange style code?

I want to highlight some code~ish thing in a report like this:

blahblahblah...Then you should use ./runprog to start up the program etc etc...

How can I do this?

Use the colorbox command from xcolor package:

\documentclass{article}

\usepackage{xcolor}
\newcommand{\SEBox}[1]{\texttt{\colorbox{gray!14}{#1}}}

\begin{document}
\SEBox{blahblah}
\end{document}


• It works! Thank you! Could you kindly explain for me what is this command doing? Jun 8, 2015 at 6:40
• \texttt changes font to typewriter style; \colorbox changes the text background color to 10% transparent gray (gray!10). Jun 8, 2015 at 6:42
• What are [1] and {#1}? Jun 8, 2015 at 6:44
• [1] number of arguments passed to the command, and #1 means use argument #1 here. For example, you can write \newcommand{\SEBox}[2][gray!10]{\texttt{\colorbox{#2}{#1}}} to be able to change the background color. Check this out: emerson.emory.edu/services/latex/latex_19.html Jun 8, 2015 at 6:46
• @anetworknoobie You ought to read about command definitions etc. Just search things like "newcommand latex" on google and on this site and you'll find tons of resources about that. If you are using linux or mac be aware that you probably have texdoc installed. So if you want to learn about a certain package you can just launch from the terminal texdoc package-name to see its documentation (e.g. texdoc mathtools). Jun 8, 2015 at 9:43