How can I force \lstinputlisting[...]{filename} to obey all parameters set by \lstset? (Note the float option given to the TeX example, but not to the LaTeX example.)

Hello, World!


  Hello, World!




\lstinputlisting[language = TeX, float, caption=A \TeX\ example]
\lstinputlisting[language = {[LaTeX]TeX}, caption=A \LaTeX\ example]



The documentation says about float:

makes sense on individual displayed listings only and lets them float.

Thus it might be a feature, that option float cannot be set globally.

Nevertheless, the following workaround seems to work:

  • 1
    So basically, this is by design? How strange. Thanks for the workaround! – Sean Allred Aug 17 '13 at 20:21
  • I don't understand that either. It would make perfect sense for me to have all my listings floating. – rbs Aug 30 '18 at 16:52
  • @rbs That's a question for the package author. – Heiko Oberdiek Aug 30 '18 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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