Tuukka Toivonen a écrit :

> On Tue, 12 Sep 2000, John Culleton wrote:
>
> > You can convert ps documents to pdf using ps2pdf. I find this the surest
>
> Yes, but the fonts (at least for math) will be bitmapped, which means
> that they look ugly with acroread and don't work at all with xpdf.
> It will be fine with gv, though.
>
> It is probably better to use pdftex/pdflatex, which works fine as long
> as you don't have pictures (althought you might need to modify the
> tex file produced by lyx). The problem is just the pictures, pdftex
> will not accept eps files (afaik). You need to convert them to pdf or
> something else.

To convert the .eps pictures, you can use the epstopdf script. To produce
your pdf document, you can use the lyx2pdf script (that call epstopdf), that
is as attached file.

BG



#      lyx2pdf - script for translating lyx docs to pdf
#
#      Copyright (C) 2000 by Steffen Evers ([EMAIL PROTECTED])
#
#      This program is free software; you can redistribute it and/or modify
#      it under the terms of the GNU General Public License as published by
#      the Free Software Foundation; either version 2 of the License, or
#      (at your option) any later version.
#
#      This program is distributed in the hope that it will be useful,
#      but WITHOUT ANY WARRANTY; without even the implied warranty of
#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#      GNU General Public License for more details.
#
#      You should have received a copy of the GNU General Public License
#      along with this program; if not, write to the Free Software
#      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Credits:
# Thanks to Matej Cepl and Herbert Voss for helping me with latex stuff!
#
# Version History:
#
# Aug 13th, 2000 -- Version 1.2
#   initial version
#

##### You will need pdftex and epstopdf for the translation!
##### See pdftex homepage for details: <A  
HREF="http://tug.org/applications/pdftex/">http://tug.org/applications/pdftex/</A>
##### Have fun!!!

###### set environment variables
LYXDOC=$1
DOCUMENTBASE=`basename $LYXDOC .lyx`
LYXPATH=`echo $LYXDOC | sed -e "s/^\(.*\)$DOCUMENTBASE\.lyx/\1/"`
TEXDOC=${LYXPATH}${DOCUMENTBASE}.tex

##### some variables not usedi ...
#VERSION=`rlog ${LYXPATH}$DOCUMENTBASE.lyx,v | sed -n "s/^head: 
\([[:digit:].]*\)$/\1/1p"`
#TRANSTIME=`date`

##### export TEX file with lyx (needs a display!)
mv $TEXDOC $TEXDOC~
lyx --export tex $1

##### get title, author and images from the produced tex file
TITLE=`sed -n "s/^.title{\(.*\)}.*$/\1/1p" $TEXDOC`
AUTHOR=`sed -n "s/^.author{\(.*\)}.*$/\1/1p" $TEXDOC`
IMAGES=`sed -n "s/^.*includegraphics{\([^}]\+\.\(e\)*ps\)}.*$/\1 /p" $TEXDOC`

echo
echo Document title: $TITLE
echo Document author: $AUTHOR
echo "Identified images (.eps/.ps):" $IMAGES
echo

####### Insert pdf conversation tags in tex file and write to foo-pdf.tex
### some possible colors:red, green, cyan, blue, magenta, black
### some possible paper sizes: a4paper, letterpaper, legalpaper, executivepaper
### see hyperref manual for more:/usr/share/texmf/doc/latex/hyperref/manual.pdf
cat $TEXDOC |
sed -e "s/\(\\includegraphics{[^}]\+\.\)\(e\)*ps}/\1pdf}/g" |
sed -e '/^\\makeatother$/i \
\\usepackage{pslatex}' |
sed -e '/^\\makeatother$/i \
\\usepackage[pdftex,pdftitle={'"$TITLE}, 
pdfauthor={$AUTHOR},linktocpage,a4paper,colorlinks=true,urlcolor=blue,citecolor=magenta]\{hyperref\}"
 > ${LYXPATH}${DOCUMENTBASE}-pdf.tex


####### Convert eps images to pdf
PDFIMAGES=
for image in $IMAGES
do
 IMAGENAME=`basename $image`
 IMAGEPATH=`echo "$image" | sed -n "s/^\(.*\)$IMAGENAME$/\1/p"`
 IMAGEBASE=`basename $IMAGENAME .eps`
 IMAGEBASE=`basename $IMAGEBASE .ps`
   if [ `echo $image | cut -c 1` != "/" ]
   then
      # relative pathname
      IMAGEPATH=${LYXPATH}$IMAGEPATH
   fi
   echo Converting image ${IMAGENAME} to pdf
   epstopdf -outfile=${IMAGEPATH}${IMAGEBASE}.pdf ${IMAGEPATH}${IMAGENAME}
   PDFIMAGES="$PDFIMAGES ${IMAGEPATH}${IMAGEBASE}.pdf"
done

######## Run pdflatex 9 times
# for runno in 1 # 2 3 # 4 5 6 7 8 9
runno=1
rerun=1
PDFLATEX=pdflatex
while [ $rerun -ne 0 ]
do
   echo
   echo "************ PDF Latex run no. $runno *************"
   echo
  rerun=`$PDFLATEX ${LYXPATH}${DOCUMENTBASE}-pdf.tex | \
         grep "LaTeX Warning: There were undefined references" | wc -l`
done

### Clean up
mv ${LYXPATH}${DOCUMENTBASE}-pdf.pdf ${LYXPATH}${DOCUMENTBASE}.pdf
rm ${LYXPATH}${DOCUMENTBASE}-pdf.* $PDFIMAGES

echo
echo "The new pdf file is: ${LYXPATH}${DOCUMENTBASE}.pdf"
echo

Reply via email to