I am grabbing data from some configuration files using literalinclude.
These files are plain ASCII and are properly processed for the HTML
documentation. For the PDF, however, the lines are too long, and get
clipped out. I understand that this is because sphinx is putting the
contents into a Verbatim environment, that doesn't do line breaks.
I can't modify the input files and split them, as they are
configuration files. I was wondering whether there's something to let
latex/sphinx know that I want those lines wrapped? I think the
listings or minted packages deals with this problem, but haven't seen
them used in conjunction with sphinx.
> I am grabbing data from some configuration files using literalinclude. > These files are plain ASCII and are properly processed for the HTML > documentation. For the PDF, however, the lines are too long, and get > clipped out. I understand that this is because sphinx is putting the > contents into a Verbatim environment, that doesn't do line breaks. > I can't modify the input files and split them, as they are > configuration files. I was wondering whether there's something to let > latex/sphinx know that I want those lines wrapped? I think the > listings or minted packages deals with this problem, but haven't seen > them used in conjunction with sphinx.
The Docutils latex writer has a config option to use the listings environment for literal blocks. I don't know whether this is ported to Sphinx, though.
Another option is to define a different "teletype" font in the LaTeX preamble, e.g. with
On 10 February 2012 22:18, Guenter Milde <mi...@users.sf.net> wrote:
> The Docutils latex writer has a config option to use the listings > environment for literal blocks. I don't know whether this is ported to > Sphinx, though.
This would be ideal!
> Another option is to define a different "teletype" font in the LaTeX > preamble, e.g. with
> \renewcommand{\ttdefault}{txtt}
> But this just changes the font, and does not affect line wrapping. Or am I
>> Another option is to define a different "teletype" font in the LaTeX >> preamble, e.g. with >> \renewcommand{\ttdefault}{txtt} >> But this just changes the font, and does not affect line wrapping. Or am I > missing something?
The idea is to use a narrower font, as the default (both, courier and CM) are rather wide. In some cases this already removes the need to wrap lines.
On 11 February 2012 20:10, Guenter Milde <mi...@users.sf.net> wrote:
> On 2012-02-11, Jose Gomez-Dans wrote: > >> But this just changes the font, and does not affect line wrapping. Or > am I > > missing something?
> The idea is to use a narrower font, as the default (both, courier and CM) > are rather wide. In some cases this already removes the need to wrap lines.
This won't work here, as some of these lines are rather long (easily 400 characters), so they'll need to be wrapped (or we start using A0 for our manuals!) :-D I can edit the stuff in Verbatim environments to use listings, but this is just a manual hack to produce a quick version. Ideally, I'd like sphinx to take care of that.
> On 11 February 2012 20:10, Guenter Milde <mi...@users.sf.net> wrote: >> On 2012-02-11, Jose Gomez-Dans wrote: >> >> But this just changes the font, and does not affect line wrapping. >> >> Or am I missing something? >> The idea is to use a narrower font, as the default (both, courier and CM) >> are rather wide. In some cases this already removes the need to wrap lines. > This won't work here, as some of these lines are rather long (easily 400 > characters), so they'll need to be wrapped (or we start using A0 for our > manuals!) :-D
I see.
> I can edit the stuff in Verbatim environments to use listings, but this > is just a manual hack to produce a quick version. Ideally, I'd like > sphinx to take care of that.
For fixing this in Sphinx, there are several options:
a) As a quick fix, overwrite the visit_literal_block/depart_literal_block methods in the latex writer to use listings.
b) As a medium fix, port the "literal_block_env" setting and its handling from the Docutils latex writer (docutils/docutils/writers/latex2e/__init__.py) to the Sphinx latex writer.
c) As a proper fix, let Sphinx use the Docutils latex writer (just like it does use the Docutils html writer).
Of course, you can also file a bug report instead of doing it yourself.