Generaldifferent font size lstinline and lstinputlisting

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Dosihris
Posts: 4
Joined: Sat Mar 01, 2008 3:41 pm

different font size lstinline and lstinputlisting

Post by Dosihris »

Hi,

can anybody tell me how to change the font size automatically in all inline listings? Normal listings should be in a smaller size. I wrote an own environment for C# (\lstdefinelanguage{CS}), but all my inline listings and my normal listings use this environment. If i change the size there, all sizes change. but i only want to change the inline listing size because i want it in the same size as the normal text.

Nico

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

different font size lstinline and lstinputlisting

Post by Stefan Kottwitz »

Hi Nico,

if you don't find a solution in the listings documentation I can offer you a solution using internal macros, for example:

Code: Select all

\makeatletter
\lst@AddToHook{TextStyle}{\let\lst@basicstyle\normalsize}
\makeatother
Stefan
LaTeX.org admin
Dosihris
Posts: 4
Joined: Sat Mar 01, 2008 3:41 pm

different font size lstinline and lstinputlisting

Post by Dosihris »

wow.. just working... cool.. thank you.

By the way, i did it like this, because i just wanted to change the size and not the font itself:

Code: Select all

\makeatletter
\lst@AddToHook{TextStyle}{\let\lst@basicstyle\ttfamily\normalsize\fontfamily{pcr}\selectfont}
\makeatother
ricombination
Posts: 1
Joined: Thu Apr 23, 2009 4:11 pm

Re: different font size lstinline and lstinputlisting

Post by ricombination »

Thank's a lot for that piece code. Very useful.
Post Reply