On Wed, Jan 03, 2007 at 01:27:25PM +0100, [EMAIL PROTECTED] wrote: > On Wed, 3 Jan 2007, Georg Baum wrote: > > >> LyX could ask whether one wants to store a copy of the image besides > >> the .lyx file... Just a thought. > > > > That would be sensible IMHO, but still not the standard behaviour one is > > used from word processors that Enrico demands above. > > So Enrico probably wants to be able to store images inside the .lyx-file?
No, that was not my intention, even if the possibility to internally store a postscript file or other textual formats (xfig, etc.) could be considered, IMO. > I think it should wait until an XML file format has been introduced. From > a discussion on the Dia list, they seemed to think that embedding an image > within the XML-file was relatively easy, so it ought to be easy for LyX as > well. If it was done before XML is introduced, it would have to be done > again. I think that one of the most interesting features of LyX is that its file format is text, and this feature should be maintained. Perhaps binary formats could be encoded, though. > Alternatively, support could be added for dealing with archives, where the > archive is comprised of the .lyx-file(s) in addition to image files and > other files needed to compile the document. It's probably a bit tricky to > get it fully automatic as some of the external files may include more > external files. The user might just be better of by placing all the > relevant files in a subdirectory and make an archive out of that manually. Once I improved a script which collected all files used by LyX in a tar archive. I am attaching here this script. It is a Bourne shell script, but I think that Bo would be able to easily convert it to python. If there's interest it could even be distributed with LyX. I think that it is better than nothing. -- Enrico
#!/bin/sh # This script creates a tar archive with a lyx file and all included files # (graphics and so on). The tar archive can be compressed with bzip2 or gzip. # # Author: Marcin Bukat # email : [EMAIL PROTECTED] # This script is a FREE software # Use at Your own risk # # Modified by Enrico Forestieri <[EMAIL PROTECTED]> to: # - make it also work on solaris # - recusively collect included files pulled in by \input{} # - allow for spaces in path names (but not carets ;-) # - account for multiple bibtex files # - avoid duplicate inclusions # - only collect files which are in the same subtree as the lyx file # # Note: to allow for a space in path names I had to disallow another char. # By default this is the caret '^' but it can be changed through an option. #Prints usage instructions usage () { echo "Usage: `basename $0` [-c <char>] [-o <dir>] [-j|-z] path/to/file.lyx" echo "Options:" echo " -c specify the forbidden char in path names" echo " -o specify the output directory" echo " -j compress with bzip2" echo " -z compress with gzip" exit } #Recursively gather files gatherFiles () { LYXNAME=$1 DIRNAME=`dirname "$1"` #Check if the bibtex .bst/.bib files are in the working directory to pack them for file in `cat "$LYXNAME"|grep -E "BibTeX|bibtex"|sed 's/.*\[\(.*\)\].*{\(.*\)}.*/\1,\2/'|tr ', ' ' ,'` do file=`echo $file|tr ',' ' '` if [ -f "$DIRNAME/$file.bst" -o -f "$DIRNAME/$file.bib" ]; then cd "`eval dirname \\\"$DIRNAME/$file\\\"`" reldir=`pwd|sed -e "[EMAIL PROTECTED](.*\)@\1@" -e "[EMAIL PROTECTED]/\(.*\)@\1@"` if [ -n "$reldir" ]; then reldir=$reldir/; fi file=`basename "$file"` cd "$WORKDIR" if [ -f "$reldir$file.bst" ]; then INCFILES="\"$reldir$file.bst\"\\\\n$INCFILES" elif [ -f "$reldir$file.bib" ]; then INCFILES="\"$reldir$file.bib\"\\\\n$INCFILES" fi fi done # Gather figure files. # Watch out for carriage returns and delete them (done by the last tr). for file in `cat "$LYXNAME"|egrep "^[[:space:]]*filename "|sed 's/.*filename *\(.*\)/\1/'|tr " " "$FC"|tr -d "\r"` do file=`echo $file|tr "$FC" " "` if [ -f "$DIRNAME/$file" ]; then cd "`eval dirname \\\"$DIRNAME/$file\\\"`" reldir=`pwd|sed -e "[EMAIL PROTECTED](.*\)@\1@" -e "[EMAIL PROTECTED]/\(.*\)@\1@"` if [ -n "$reldir" ]; then reldir=$reldir/; fi file=`basename "$file"` cd "$WORKDIR" if [ -f "$reldir$file" ]; then INCFILES="\"$reldir$file\"\\\\n$INCFILES" fi fi done # Gather input files. # If file.pstex_t is \input{}ed then add file.pstex to the list, too. for file in `cat "$LYXNAME"|grep \\\\input\{|sed 's/.*\\input{ *\(.*\) *}.*/\1/'|tr " " "$FC"` do file=`echo $file|tr "$FC" " "` if [ -f "$DIRNAME/$file" ]; then cd "`eval dirname \\\"$DIRNAME/$file\\\"`" reldir=`pwd|sed -e "[EMAIL PROTECTED](.*\)@\1@" -e "[EMAIL PROTECTED]/\(.*\)@\1@"` if [ -n "$reldir" ]; then reldir=$reldir/; fi file=`basename "$file"` cd "$WORKDIR" if [ -f "$reldir$file" ]; then INCFILES="\"$reldir$file\"\\\\n$INCFILES" EXT=`echo $file | sed 's/.*\.\(.*\)/\1/'` if [ "x$EXT" = "xpstex_t" ]; then bname=`basename "$file" .pstex_t` INCFILES="\"$reldir$bname.pstex\"\\\\n$INCFILES" elif [ "x$EXT" = "xlyx" ]; then bname=`basename "$file"` gatherFiles "$reldir$file" fi fi fi done } #Creates archive archive () { ARCHNAME=`basename "$LYXFILENAME" lyx`tar case "$1" in -j) COMPRESS="bzip2" ARCHNAME="$ARCHNAME.bz2" ;; -z) COMPRESS="gzip" ARCHNAME="$ARCHNAME.gz" ;; *) COMPRESS="cat" esac cd "$WORKDIR" WORKDIR=`pwd` gatherFiles "$LYXFILENAME" if [ -n "$INCFILES" ]; then INCFILES=`eval printf $INCFILES | sort | uniq | xargs -i%s echo "\"%s\" "` fi eval tar cv \"$LYXFILENAME\" $INCFILES | $COMPRESS > $OUTDIR$ARCHNAME if [ $? -eq 0 ]; then echo "Lyx archive \"$OUTDIR$ARCHNAME\" created successfully" else exit 1 fi } #Main part starts here #Check if there is any parameter if [ $# -eq 0 ]; then usage else LYXFILENAME="" OUTDIR="" PARAM="-" FC="^" while [ $# -gt 0 ] do case "$1" in -c) if [ $# -gt 1 ]; then FC=$2; else usage; fi shift 2 ;; -c*) FC=`echo $1|sed 's/-c//'` shift ;; -o) if [ $# -gt 1 ]; then OUTDIR=$2; else usage; fi shift 2 ;; -o*) OUTDIR=`echo $1|sed 's/-o//'` shift ;; -j|-z) PARAM=$1 shift ;; *) if [ -n "$LYXFILENAME" ]; then usage; fi LYXFILENAME=`basename "$1"` WORKDIR=`dirname "$1"` shift esac done fi if [ -f "$WORKDIR/$LYXFILENAME" ]; then if [ -n "`echo $FC|sed 's/^.\(.*\)/\1/'`" ]; then usage; fi if [ -n "$OUTDIR" ]; then OUTDIR=$OUTDIR/; fi #parameters are correct so make archive archive $PARAM else echo "`basename $0`: cannot find \"$WORKDIR/$LYXFILENAME\"" exit 1 fi