TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My document starts with:

\begin{document}
\lstset{ %
  language=Java,
  float=tb
}

However all listings appear exactly just where they have been defined, e.g. this one:

\begin{lstlisting}[label=fig:jaxrs-annotated-resource-example,
                   caption={Example of a JAX-RS annotated Resource class (by Marek Potociar)}]
@Path("atm/{cardId}")   
public class AtmResource {  
`  
  @GET  
  @Path("balance")  
  @Produces("text/plain")   
  public String balance(@PathParam("cardId") String card,   
                        @QueryParam("pin") String pin) {    
    return Double.toString(getBalance(card, pin));  
  }
\end{lstlisting}

Do you already see sth. wrong or do I need to find a minimal document with this issue? My full document is here: https://github.com/thkoch2001/bachelor-thesis/blob/master/latex/restful_groupware.tex

share|improve this question
up vote 6 down vote accepted

Although this seems clearly to be a bug, a work-around is the define a new listing environment:

\lstnewenvironment{javalisting}[1][]
  {\lstset{language=Java,float=tb,#1}}% \begin{javalisting}[...]
  {} % \end{javalisting}
share|improve this answer
    
Danke! Der Workaround funktioniert. Ich hatte nur Probleme, weil ich das \lstnewenvironment ohne die "Kommentare"(?) nach den % Zeichen kopiert habe. Oh latex... – Thomas Koch Feb 6 '12 at 14:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.