Featured Book

LaTeX Beginners Guide

Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 12 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

listings | Appendix with custom Setup for Code Listings Topic is solved

Add tags LaTeX specific issues not fitting into one of the other forums of this category.

listings | Appendix with custom Setup for Code Listings

Postby Superfox_il_Volpone on Sat Nov 17th, 2012

Hi guys,

first topic here. I am a newbie, attempting to end my first report.

I need to insert C++ code in the appendix, and what I'd like to obtain is to have a particular style for the lstlisting environment (for C++ and with smaller font) only for the appendix, while preserving the unspecialised style for the rest of the document.

Another nice feature would be having a different margin for the pages in the appendix. What is the solution?


Regards
- s.fox
Superfox_il_Volpone
 
Posts: 3
Joined: Sat Nov 17th, 2012

Re: listings | Appendix with custom Setup for Code Listings  Topic is solved

Postby hugovdberg on Sat Nov 17th, 2012

Regarding the listings package, you can use \lstset anywhere in the document, and it will affect only the following listings. See documentation for more information.

Changing the margins in the appendix could be done with the geometry package, or possibly through a different construction depending on the document class you use.

A small example of how this could be done:
Code: Select all  •  Open in writeLaTeX
\documentclass{article}

\usepackage{geometry}
\usepackage{listings}
\geometry{margin=2in}

\begin{document}
\begin{lstlisting}
  program hello
    implicit none
     
    print *, 'Hello World'
  end program
\end{lstlisting}

\newgeometry{margin=0.1in}
\clearpage
\lstset{
  language=[95]fortran,
  basicstyle=\small\ttfamily,
  keywordstyle=\bfseries,
  frame=single,
}
\begin{lstlisting}
  program hello
    implicit none
     
    print *, 'Hello World'
  end program
\end{lstlisting}

\end{document
}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
hugovdberg
 
Posts: 133
Joined: Sat Feb 25th, 2012
Location: 's-Hertogenbosch, Netherlands

Re: listings | Appendix with custom Setup for Code Listings

Postby Superfox_il_Volpone on Sat Nov 17th, 2012

thank you, it worked!

regards
- s.fox
Superfox_il_Volpone
 
Posts: 3
Joined: Sat Nov 17th, 2012


Return to General

Who is online

Users browsing this forum: No registered users and 12 guests