LaTeX forum ⇒ Generallistings | Appendix with custom Setup for Code Listings Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Superfox_il_Volpone
Posts: 3
Joined: Sat Nov 17, 2012 1:08 am

listings | Appendix with custom Setup for Code Listings

Postby Superfox_il_Volpone » Sat Nov 17, 2012 1:14 am

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

Link:
BBcode:
HTML:
Hide post links
Show post links

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
Location: 's-Hertogenbosch, Netherlands

Postby hugovdberg » Sat Nov 17, 2012 12:00 pm

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:
  1. \documentclass{article}
  2.  
  3. \usepackage{geometry}
  4. \usepackage{listings}
  5. \geometry{margin=2in}
  6.  
  7. \begin{document}
  8. \begin{lstlisting}
  9. program hello
  10. implicit none
  11.  
  12. print *, 'Hello World'
  13. end program
  14. \end{lstlisting}
  15.  
  16. \newgeometry{margin=0.1in}
  17. \clearpage
  18. \lstset{
  19. language=[95]fortran,
  20. basicstyle=\small\ttfamily,
  21. keywordstyle=\bfseries,
  22. frame=single,
  23. }
  24. \begin{lstlisting}
  25. program hello
  26. implicit none
  27.  
  28. print *, 'Hello World'
  29. end program
  30. \end{lstlisting}
  31.  
  32. \end{document}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Link:
BBcode: Topic is solved[/url]" title="Click to select post's link in BBcode format" onclick="this.focus();this.select();" />
HTML: Topic is solved</a>" title="Click to select post's link in HTML format" onclick="this.focus();this.select();" />
Hide post links
Show post links

Superfox_il_Volpone
Posts: 3
Joined: Sat Nov 17, 2012 1:08 am

Postby Superfox_il_Volpone » Sat Nov 17, 2012 10:02 pm

thank you, it worked!

regards
- s.fox

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “General”

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot] and 7 guests