Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

barbie (2653)

barbie
  reversethis-{ku. ... m} {ta} {eibrab}
http://barbie.missbarbell.co.uk/

Leader of Birmingham.pm [pm.org] and a CPAN author [cpan.org]. Co-organised YAPC::Europe in 2006 and the 2009 QA Hackathon, responsible for the YAPC Conference Surveys [yapc-surveys.org] and the QA Hackathon [qa-hackathon.org] websites. Also the current caretaker for the CPAN Testers websites and data stores.

If you really want to find out more, buy me a Guinness ;)

Links:
Memoirs of a Roadie [missbarbell.co.uk]
[pm.org]
CPAN Testers Reports [cpantesters.org]
YAPC Conference Surveys [yapc-surveys.org]
QA Hackathon [qa-hackathon.org]

Journal of barbie (2653)

Thursday October 18, 2007
04:34 AM

Learning LaTeX

[ #34711 ]

I've been a bit quiet for the past month or so, mostly because projects both at work and home have taken up a lot of my time. One of the home projects has involved creating some report documents in PDF. When first thinking about this, I was looking at PDF::API2, and various other PDF modules, but was struck at how much layout work is put into the code. I don't like having to mix the two, as if I have to change anything in the layout it means changing the code. Reading a recent article on perl.com only reaffirms that. If you're creating a special document, this might work for you, but it doesn't for me.

Thanks to Andrew Ford and wikibooks, I have been learning how to mix LaTeX with Template Toolkit. My current installed version of the plugin (2.17) doesn't go as far as I need it to at the moment, but the newest version and its new dependency, Latex::Driver, do. Unfortunately I've been finding problems with it on Win32, so I'm currently working through those with Andrew and hopefully he'll be able to get a working Win32 version out soon.

However, following Andrew's encouragement to look at Latex, I was quite impressed at just how easy it was to learn the basics, and in fact I kind of jumped in at the deep end and was creating complex headers, footers, tables and graphics in my first document. I found a problem though, that none of the expert forums seem to have solved, as I want to swap a page layout from Portrait to Landscape mid document, but apart from that everything has worked wonderfully.

If you are ever in a situation where you need to produce regular reports from various data sources, and templating would feel a natural way to go, I heartily recommend looking at Latex with Template Toolkit.

Andrew will be giving an introduction to his modules at the next Birmingham Perl Mongers technical meeting. If I can manage it, I'll see whether I can record it on video. Assuming Andrew doesn't mind of course :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • LaTeX is great. If you need help, count on me.
  • You probably want the "lscape" package, which provides a "landscape" environment.
    • Unfortunately that only turns the content by 90 degrees, not the whole page layout. As such the headers and footers still appear in portrait mode. Yeah I tried that ;)

      • Do you want text to flow on and off the landscape pages? If not, I'd suggest just concatenating separate documents, and using "\setcounter{page}{N}" to get the page numbering right. If so, it's hard to understand exactly what you want to happen, since LaTeX can move text around a lot when formatting.
  • I might be misreading what you're seeking, but maybe something like the following will do the portrait/landscape shuffle?
    ==============================

    \documentclass[11pt]{article}
    \usepackage{pdflscape}

    \begin{document}

    \section{Some junk}

    \begin{landscape}

    \pagestyle{empty} %odd page number suppressed!

    \section{The second section...}
    Some more junk, on a landscape page in the pdf output.

    \end{landscape}

    \section{Back to sanity, in portrait mode...}

    \end{document}
    • As per the reply above, this only rotates the content, not the page layout. The headers and footers are still printed in portrait mode :(

      If you find a solution, I'll be most impressed as I've yet to find anything in any online or printed material that describes how to do this, including the definitive LaTeX Companion [amazon.co.uk] book, that is well worth buying for anyone interested in LaTeX.

  • I've used LaTeX in the past but if I were needing to generate printed reports now, I'd be seriously looking at Prince. If only it were a little more free.

    http://www.princexml.com/ [princexml.com]
  • That will print the whole document sideways.
    • I think you might have misunderstood what I was after. I know how to get the whole document to print in either Portrait OR Landscape, but I want to create a document that allows both in the same document. All the options have so far only allowed the content to rotate NOT the complete page layout, i.e. including headers and footers.

  • If you can do with Template Toolkit, LaTeX to PDF is great.

    But if you want to produce Business Reports, like inventory lists, Invoices, Acoount Balances and so on, you need more precision. At least in my experience you do.

    Whenever I get the time (and I will, Real Soon Now, promise!) I will look into this again and rewrite/refactor a module I made long time ago for this purpose.
    • Excellent. I look forward to seeing the results. You might want to talk to Andrew Ford, as he is very keen to get other LaTeX functionality usable within Template Toolkit.

      For my purposes Template Toolkit provides the data and graphics needed to create the .tex file, then LaTeX takes over via Latex::Driver.