13
votes
2answers
151 views

Filecontents and newenvironment issue

I need to write some inlined code on an external file, then load it with listings. I would like to define a new environment, but if I do, filecontents does not save the first line of code (see MWE): ...
2
votes
1answer
539 views

Lstinputlisting and listings styles

To further extend my recent question about new listings environments, found here: Multiple listings styles. How do I define a new lstlistings environment, via the command \lstnewenvironment, and, be ...
6
votes
1answer
387 views

Listings line numbers that match the linerange specification

This is a follow-up question to First line number in lstinputlisting environment. Consider the MWE: \documentclass{article} %\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox ...
4
votes
1answer
227 views

Command to insert filename in caption of a listing

I would like to have a command to insert listings that contain the filename in the caption. This works well as long as there is no "_" etc. in the filename. I also tried the suggestion from a ...
5
votes
1answer
3k views

Including XML file into LaTeX

I am using LaTeX for very first time and have very basic knowledge about it. I am using the template from here to write my thesis. I am using Ubuntu 12.04. When I try to include a small XML file in ...
3
votes
1answer
123 views

Auto include specific part of source files

I'm creating a lot of code to our small projects (in computer science), and finding myself copy/pasting my comments into the document. Would it be possible to make a reference point in the code file ...
2
votes
1answer
1k views

\lstinputlisting for a normal text file?

sometimes im using \lstinputlisting to show some code examples in my pdf. Now I just would like to insert a normal textfile. Everything is fine, I like this box around my text and the numbers every ...
4
votes
2answers
2k views

Inserting Code in multiple pages as an appendix

I am trying to insert a script (bash shell code) to the appendix of my document. I am trying to import the script from separate file. The script file name is Event_Db_BckUp_Script.als. The problem is ...
2
votes
1answer
292 views

treating multiple code listings as one figure (listings package)

Please note that I am quite new to tex/latex. For my paper I need to reference specific parts of my source code as one code listing. This allows me to skip specific lines of the source code that are ...
1
vote
1answer
665 views

Pointing to Java files not in root latex folder using listings

I am trying to use listings to point to a Java source code file. The file path is different from the Latex document. Below is an example of what I am trying to do, though it doesn't compile it says it ...
4
votes
1answer
330 views

Using listings for R code with ## in rangeprefix

In R, comments are preceded by the symbol #. Moreover, to avoid messing with the indentation, it's usually ## instead of #. Therefore, as I want to include some R code in a LaTeX document, I am using ...
3
votes
1answer
1k views

Showing only specific lines using the listings package

I am very new to TeX. My source code is in an external file, let's call it source.java, and I use \lstinputlisting{source.java}. How could I use only the lines 3-5 for my code listing? (and not the ...
12
votes
1answer
1k views

How can I pass underscore to \newcommand properly?

I'd like to simplify my code appendix with this command definition: \usepackage{listings} % ... \newcommand{\CodeListing}[1]{% \lstinputlisting[caption=#1]{#1}% } That is, the caption should be ...
8
votes
1answer
3k views

How to make \lstinputlisting applicable to file paths with spaces?

I am using the listings package and the path to the source code contains some spaces. For example, the path can be /some dir/sub dir/file 1.txt and \lstinputlisting{/some dir/sub dir/file 1.txt} does ...