On Saturday 06 June 2009 02:02:25 am John McCabe-Dansted wrote:
> Often proceedings give authors sample .tex files to demonstrate how a
> paper should be formatted. I generally want to make my preamble as
> close as possible the sample. Usually I can trick LyX into generating
> something pretty close to the sample preamble, but before submitting
> manually tweak the .tex file to remove unneeded options etc. For lolz,
> I spend a couple of days in LyX getting the pagination just right,
> then discover that the pagination changes once I manually fix the
> preabmle in the .tex file. Additionally, it is much faster to
> cut-and-paste a preamble than it is to hunt round in LyX to find all
> the options.  For these reasons, I use a wrapper script around
> pdflatex like the one below.
>
> However I was wondering if this sounds like a good feature for LyX itself?
>
> My suggested implementation would be that you can set an option in
> Document Settings->LaTeX Preamble like "edit whole preamble". When
> this option is set LyX copies the whole preamble into the text box,
> and allows the user to edit it as normal text.
>
> -- pdflatex --
> #!/bin/bash
> THIS_SCRIPT="$0"
> echo AT "$@"
> echo AT "$@" 1>&2
> echo AT "$@"  > /tmp/AT
>
> echo "$*" | grep -o '\b[^ ]*.tex' | head -n1 | (
>       read texfile
>       echo TEXFILE $texfile
>       mv $texfile $texfile.orig
>       grep '^%PREAM ' $texfile.orig | sed 's/^%PREAM //' > $texfile
>       "$THIS_SCRIPT".strip_preamble.py < $texfile.orig >> $texfile
>       /usr/bin/pdflatex "$@"
>       rm $texfile.mod
>       mv $texfile $texfile.mod
>       mv $texfile.orig $texfile
> )
>
> -- pdflatex.strip_preamble.py --
> #!/usr/bin/env python
> import sys
>
> preamble=True;
> for line in sys.stdin:
>       if preamble:
>               if line == '\\begin{document}\n':
>                       preamble=False
>                       print line,
>       else:
>                       print line,


Stylesheets provided by others are always a good thing. Who wants to decide on 
formatting when someone else can make the decision? (unless of course you're 
selling the result directly to the public).

Drop-in LaTeX stylesheets would be a great LyX feature if a large number of 
LyX users would use it. Otherwise it should probably be a script, which 
you've already made.

I had trouble visualizing everything your script does. Does it take into 
account a layout file with multiple Preample/EndPreamble pairs?

Thanks

SteveT

Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt

Reply via email to