0

I am using the answer here to add source code to my beamer (usually inline), as:

\usepackage{xcolor}
\definecolor{light-gray}{gray}{0.95}
\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}}}

But then some lines of code cannot fit to a single line, so I have to reduce the font size to fit.

enter image description here

Then I add a font size to the \code command like:

\newcommand{\code}[1]{\colorbox{light-gray}{\texttt{#1}[10pt]{\fontsize{#2}{#1}\selectfont #3}}}

This doesn't work. What's the correct way of doing this?

0

1 Answer 1

1

You might change the definition into

\newcommand{\code}[2][]{\colorbox{light-gray}{\texttt{#1#2}}}

so you can call

\code{Some code to typeset}

or

\code[\tiny]{Some code to typeset}

Any font size changing command can be used as the optional argument. Even \fontsize{2}{0}\selectfont if you really want to make the slide unreadable. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .