[Haskell-cafe] lhs2TeX: automatic line wrap within code blocks?

David Mihola david.mihola at gmail.com
Thu Apr 5 08:33:00 CEST 2012


Dominique,

thank you very much for your reply!

Yes, that would work for the code-blocks, but I'd still prefer
automatic line wrapping like in this example:

http://www.bollchen.de/blog/2011/04/good-looking-line-breaks-with-the-listings-package/

Also this does not solve the case of multi line results in eval-statements.

But still, thanks again - and as my deadline draws nearer (this is
homework in a security lecture) I may use your solution and also
decrypt the text first and then copy the decrypted text into the
source file (to get rid of the eval-statement).

David

Am 5. April 2012 08:01 schrieb Dominique Devriese
<dominique.devriese at cs.kuleuven.be>:
> David,
>
> The easiest solution is probably to use multi-line string literals and
> line-wrap manually:
>
> \begin{code}
> cyphertext = "rlkmlj, zlnift ekblvke pqc elvm if pzlp gblrk, akrlomk zk zle \
>  lfpiriglpke pzlp, if pzk flpojlb rcojmk cs knkfpm, morz qcobe ak pzk rcfeorp \
>  cs nkjriftkpcjiu, bklnkm pzk ljdv ofekj gjkpkfmk cs jlimift jkrjoipm lfe \
>  rlnlbjv"
> \end{code}
>
> Dominique
>
> Op 4 april 2012 20:14 heeft david.mihola <david.mihola at gmail.com> het
> volgende geschreven:
>> Hello,
>>
>> I am currently using lhs2TeX for the first time and have encountered a
>> problem which I am unable to solve myself: Some code lines are too long to
>> fit into a single line of the output (PDF) file and thus go off the right
>> edge of the page.
>>
>> Consider the following example:
>>
>> -------------------------------------
>>
>> \documentclass{article}
>> \usepackage[utf8]{inputenc}
>>
>> %include polycode.fmt
>> %options ghci
>> \begin{document}
>>
>> Our encrypted message:
>>
>> \begin{code}
>> cyphertext = "rlkmlj, zlnift ekblvke pqc elvm if pzlp gblrk, akrlomk zk zle
>> lfpiriglpke pzlp, if pzk flpojlb rcojmk cs knkfpm, morz qcobe ak pzk rcfeorp
>> cs nkjriftkpcjiu, bklnkm pzk ljdv ofekj gjkpkfmk cs jlimift jkrjoipm lfe
>> rlnlbjv"
>> \end{code}
>>
>> Our decryption function:
>>
>> \begin{code}
>> decrypt = id
>> \end{code}
>>
>> The original message was:
>>
>> \eval{decrypt cyphertext}
>>
>> \end{document}
>>
>> -------------------------------------
>>
>> Converting this to .tex with lhs2TeX and to .pdf with pdflatex produces a
>> PDF in which both instances of the cyphertext go off the right edge of the
>> page.
>>
>> Is there any way to tell lhs2TeX to allow/force line wrap within code blocks
>> and eval-statements?
>>
>> Thank you very much for any help!
>>
>> David
>>
>> P.S.: I have only found one prior discussion of my question
>> (http://tex.stackexchange.com/questions/15048/how-to-typeset-a-multiline-text-in-math-environment)
>> but to my understanding no real answer came out of that.
>>
>> --
>> View this message in context: http://haskell.1045720.n5.nabble.com/lhs2TeX-automatic-line-wrap-within-code-blocks-tp5618600p5618600.html
>> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list