3

I found a hint from Karl Berry written 4 years ago about how to get line wrapping in code samples, in texi2pdf output. I demonstrate that solution below. However, it would be interesting to know if there is a way to do this without requiring hand-tuning of the expressions that are being printed.

One possible work-around that occurred to me is to do the hand-tweaking as needed and wrap that in @ifpdf tags. But that seems to be explicitly not possible.

At present, Texinfo does not provide ‘@ifpdf’ or ‘@pdf’ commands as for the other output formats, since PDF documents contain many internal low-level offsets and references that would be hard or impossible to get right at the Texinfo source level.

\input texinfo   @c -*-texinfo-*-      
@c %**start of header
@setfilename longline.info
@settitle Long Line Sample
@c %**end of header

@node    Top
@chapter Long line example

Here is an example of a code block, it is formatted using a pair of matching @code{@@example} and @code{@@end example} tags.

@example
(["lessfrequentword" java.lang.string]
["mostfrequentword" java.lang.string]
["wordstupleswithfrequency" 
#<parameterizedtypeimpl java.util.arraylist<java.lang.string[]>>]
["words" #<parameterizedtypeimpl
 java.util.arraylist<ccg.flow.processnodes.text.retrievers.dictionary.dictionaryitem>>])
@end example

As you can see, there is no linewrapping.  What I would like is something that looks more like this:

@quotation
@t{(["lessfrequentword" java.lang.string]}@*
@t{["mostfrequentword" java.lang.string]}@*
@t{["wordstupleswithfrequency"}@*
@t{#<parameterizedtypeimpl java.util.arraylist<java.lang.string[]>>]}@*
@t{["words" #<parameterizedtypeimpl}@*
@t{ java.util.arraylist<ccg.flow.processnodes.text.retrievers.dictionary. dictionaryitem>>])}@*
@end quotation

But ideally without the need to hand-tweak the text (note extra space introduced in the
second listing in particular).

@bye

enter image description here

3

something like this might be a start

Start the file

\input texinfo   @c -*-texinfo-*-
@iftex
@input texinfoextras
@end iftex

then compiling (e.g. for Info) with

makeinfo --no-iftex texinfo.texi

to hide the input command from this processor.

For processing with texi2pdf, a sensible texinfoextras.tex could be

@catcode`@\=0
\let\oldexample\example
{
\gdef\example{\oldexample
\relax
\catcode46=\active
\def\normaldot{\string.\hfil\penalty0\hfilneg}}
}
@catcode`@\=13

which allows line wrapping on . resulting in

enter image description here

  • It seems that it can be hidden inside @iftex ... @end iftex commands and then compiling (for Info) with makeinfo --no-iftex texinfo.texi. – Joe Corneli Jun 13 '15 at 0:47
  • 1
    @JoeCorneli thanks I added that to the answer. – David Carlisle Jun 13 '15 at 9:34
  • Thanks, I augmented this to break on ; as well; it turns out that's less elegant, but in case a future visitor wants to see (or in case it can be improved): gist.github.com/holtzermann17/860ce53e67bc0dcb7762 - and I finally think I understand something about these catcodes I've been seeing all these years, from a gander at a few pages of A Beginner’s Book of TEX by Raymond Seroul. – Joe Corneli Jun 18 '15 at 22:22

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.