Re: Automatic save of LaTeX
> On Apr 20, 2016, at 5:51 PM, Anders Host-Madsenwrote: > > Hal Kierstead me.com> writes: > > >> >> Please post the final version. >> Thanks, >> Hal >> > > I wrote a step by step procedure (ironically, in MS Word! I just > find it easier to copy the screen shots into Word) for the > non-techies -- mainly so I can myself repeat the procedure > when I install a new version of LyX or get a new computer. > > I don't know how to attach with the gmane interface, but here is a link > if anyone is interested. I could also perhaps post on a Wiki? > > https://www.sugarsync.com/pf/D6910206_06659227_6503710 > > Many thanks, Hal
Re: Automatic save of LaTeX
Hal Kierstead me.com> writes: > > Please post the final version. > Thanks, > Hal > I wrote a step by step procedure (ironically, in MS Word! I just find it easier to copy the screen shots into Word) for the non-techies -- mainly so I can myself repeat the procedure when I install a new version of LyX or get a new computer. I don't know how to attach with the gmane interface, but here is a link if anyone is interested. I could also perhaps post on a Wiki? https://www.sugarsync.com/pf/D6910206_06659227_6503710
Re: Automatic save of LaTeX
> On Apr 20, 2016, at 7:42 AM, Anders Host-Madsenwrote: > > That was it, now it works exactly as intended. Thanks again > for your help. > Please post the final version. Thanks, Hal
Re: Automatic save of LaTeX
That was it, now it works exactly as intended. Thanks again for your help.
Re: Automatic save of LaTeX
Am 19.04.2016 um 17:42 schrieb Anders Host-Madsen: > > Anders Host-Madsen yahoo.com> writes: > > A few more comment on this. To get the same latex file as one would > get when exporting from the menu, set the "nice" flag in the exporter. > > The main issue with the script approach is that it changes the name > of the files. For example, spaces become _. I don't see how to solve > this. I doesn't seem the real name of the original file is available > to the converter. This is possible with a little bit more effort. 1. Add "$$f“ as 3rd parameter for your converter call in LyX preferences. 2. Extend your script similar to the following modified version: === #!/bin/sh exec >> "$HOME"/bin/iPadConvert.log echo $(date)":" "$0" "$@" filename=$(basename "$1" .tex) if [ -d "$2" ]; then targetdir="$2" elif [ -f "$2" ]; then targetdir=$(dirname "$2") else targetdir="$2" if [ ! -d "$2" ]; then echo Bad call with target "$2" exit 1 fi fi if [ -n "$3" ]; then targetname=$(basename "$3" .lyx) else targetname="$(filename)" fi echo pwd=$(pwd) filename="$filename" echo pdflatex "$1" "$targetdir"/"$targetname".pdf pdflatex "$1" && test -f "$filename".pdf && cp "$filename".pdf "$targetdir"/"$targetname".pdf echo cp "$1" "$targetdir"/"$targetname".tex cp "$1" "$targetdir"/"$targetname".tex === The point is to check for an (optional) 3rd argument to set the targetname like the LyX source file name. Stephan
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: A few more comment on this. To get the same latex file as one would get when exporting from the menu, set the "nice" flag in the exporter. The main issue with the script approach is that it changes the name of the files. For example, spaces become _. I don't see how to solve this. I doesn't seem the real name of the original file is available to the converter.
Re: Automatic save of LaTeX
OK, I found the problem. Textedit on Mac changed the quotes " into smart quotes. After correcting that it works completely. Thanks all for your help.
Re: Automatic save of LaTeX
Stephan Witt gmx.net> writes: Unfortunately it's not quite there. I have tried to modify the script to run bibtex, but it doesn't work. I have tried different variations for the input to bibtex, below is one. But it's not quite clear to me exactly what should be the input argument to bibtex. It's almost there, so I hope someone can help me. #!/bin/sh echo $(date)":" "$0" "$ " filename=$(basename "$1" .tex) if [ -d "$2" ]; then targetdir="$2" elif [ -f "$2" ]; then targetdir=$(dirname "$2") else targetdir="$2" if [ ! -d "$2" ]; then echo Bad call with target "$2" exit 1 fi fi echo pwd=$(pwd) filename="$filename" echo pdflatex "$1" "$targetdir"/"$filename".pdf pdflatex "$1" "$targetdir"/"$filename".pdf bibtex “$filename”.aux pdflatex “$1” "$targetdir"/"$filename".pdf pdflatex "$1" && test -f "$filename".pdf && cp "$filename".pdf "$targetdir"/ echo cp "$1" "$targetdir"/"$filename".tex cp "$1" "$targetdir"/"$filename".tex
Re: Automatic save of LaTeX
Stephan Witt gmx.net> writes: Thank you so much. Now it works. The key was to put the path to the script in the lyx path. I had understood from the LyX customization manual that when you put it inside the lyx scripts folder, lyx would find it. But that seems not to be the case. Also thanks for the script itself. Much more advanced than something I could write.
Re: Automatic save of LaTeX
Am 13.04.2016 um 23:55 schrieb Anders Host-Madsen: > > Paul A. Rubin msu.edu> writes: > >> Is LExport.sh marked executable by all users, not just yourself. I don't >> know whether LyX runs the script with you as the user or with LyX as the >> user. > > It should be. Here is ls -l > > -rwxrwxrwx@ 1 madsen admin 20 Apr 12 14:11 LExport.sh > >> >> Also, does the script specify a command interpreter with a hash-bang comment >> at the top? In other words, when you successfully run it outside LyX, do you >> do so with "./LExport.sh", or do you specify a command interpreter (e.g, >> "bash ./LExport.sh"? > > Yes. Here is the script (at the moment I'm just trying to make the script run, > so it doesn't do anything yet): > > #!/bin/bash > cp $1 $2 > > Perhaps it's some security issue on Mac that prevents it from running? > > Anyway, now that I know there is a message pane, I figured out exactly > where it goes wrong with the command-sequence. The issue is with copying > figures. Sometimes they don't copy, and pdflatex fails. If I have a > long LyX document, but without figures, the command-sequence seems > to always work, producing a latex and pdf file. This is working for me: 1. Create a script in "$HOME"/bin named iPadConvert.sh 1a) mkdir -p "$HOME"/bin 1b) vi "$HOME"/bin/iPadConvert.sh === #!/bin/sh exec >> "$HOME"/bin/iPadConvert.log echo $(date)":" "$0" "$@" filename=$(basename "$1" .tex) if [ -d "$2" ]; then targetdir="$2" elif [ -f "$2" ]; then targetdir=$(dirname "$2") else targetdir="$2" if [ ! -d "$2" ]; then echo Bad call with target "$2" exit 1 fi fi echo pwd=$(pwd) filename="$filename" echo pdflatex "$1" "$targetdir"/"$filename".pdf pdflatex "$1" && test -f "$filename".pdf && cp "$filename".pdf "$targetdir"/ echo cp "$1" "$targetdir"/"$filename".tex cp "$1" "$targetdir"/"$filename".tex === 1c) chmod +x "$HOME"/bin/iPadConvert.sh 2. Add $HOME/bin to PATH settings of LyX (at end with colon separator) => Preferences => Path e.g. /Library/TeX/texbin:/opt/local/teTeX/bin:/opt/local/bin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:$HOME/bin 3. Add file format and converter == \format "ipad" "" "iPad" "" "auto" "" "" „" \converter "pdflatex" "ipad" "iPadConvert.sh $$i $$r" "" == 4. Export to iPad => "$HOME"/bin/iPadConvert.log contains e.g. == Fri Apr 15 09:00:41 CEST 2016: /Users/stephan/bin/iPadConvert.sh newfile4.tex /Users/stephan/Documents/ pwd=/private/var/folders/1x/zm63s22x7s591xrlgm4rl9v4gn/T/lyx_tmpdir.HyRSsWW90987/lyx_tmpbuf0 filename=newfile4 pdflatex newfile4.tex /Users/stephan/Documents//newfile4.pdf This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (./newfile4.tex LaTeX2e <2015/01/01> Babel <3.9l> and hyphenation patterns for 79 languages loaded. cp newfile4.tex /Users/stephan/Documents//newfile4.tex == BTW, you don’t need to save the document to get the updated .tex and .pdf files... The culprit is: you need to add the location of your script to LyX’s path setting! HTH and regards, Stephan
Re: Automatic save of LaTeX
Paul A. Rubin msu.edu> writes: > Is LExport.sh marked executable by all users, not just yourself. I don't > know whether LyX runs the script with you as the user or with LyX as the user. It should be. Here is ls -l -rwxrwxrwx@ 1 madsen admin 20 Apr 12 14:11 LExport.sh > > Also, does the script specify a command interpreter with a hash-bang comment > at the top? In other words, when you successfully run it outside LyX, do you > do so with "./LExport.sh", or do you specify a command interpreter (e.g, > "bash ./LExport.sh"? Yes. Here is the script (at the moment I'm just trying to make the script run, so it doesn't do anything yet): #!/bin/bash cp $1 $2 Perhaps it's some security issue on Mac that prevents it from running? Anyway, now that I know there is a message pane, I figured out exactly where it goes wrong with the command-sequence. The issue is with copying figures. Sometimes they don't copy, and pdflatex fails. If I have a long LyX document, but without figures, the command-sequence seems to always work, producing a latex and pdf file.
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: > I have tried this method. I figured out how to write scripts and put the formats > into LyX, and how to debug LyX. But LyX just will not run my script. I > get the message > > 14:15:31.593: The process failed to start. Either the > invoked program is missing, or you may have > insufficient permissions to invoke the program. > 14:15:31.720: Successful export to format: > Exportsupport/Systemcall.cpp (276): Systemcall: 'LExport.sh > $$r "test.tex"' did not start! > support/Systemcall.cpp (277): error The process failed to start. > Either the invoked program is missing, > or you may have insufficient permissions to invoke the program. > > I have tried to put the scrip inside the LyX scripts directory, and outside. > I can run it > from terminal. But when LyX tries to run it, the above happens. Any > ideas from anyone? > It's all on a Mac. Is LExport.sh marked executable by all users, not just yourself. I don't know whether LyX runs the script with you as the user or with LyX as the user. Also, does the script specify a command interpreter with a hash-bang comment at the top? In other words, when you successfully run it outside LyX, do you do so with "./LExport.sh", or do you specify a command interpreter (e.g, "bash ./LExport.sh"? Paul
Re: Automatic save of LaTeX
Paul A. Rubin msu.edu> writes: > > > Yes, this is what I meant, and the sequence you listed is what I would use. > I don't know if it will work in 100% of all cases, but at worst you should > have the .lyx and .tex files saved (and a LaTeX log file indicating why > compilation failed), or maybe a PDF file with those annoying question marks > where you were hoping for cross-references. > > I have tried this method. I figured out how to write scripts and put the formats into LyX, and how to debug LyX. But LyX just will not run my script. I get the message 14:15:31.593: The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. 14:15:31.720: Successful export to format: Exportsupport/Systemcall.cpp (276): Systemcall: 'LExport.sh $$r "test.tex"' did not start! support/Systemcall.cpp (277): error The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. I have tried to put the scrip inside the LyX scripts directory, and outside. I can run it from terminal. But when LyX tries to run it, the above happens. Any ideas from anyone? It's all on a Mac.
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: > > This sounds a little challenging. By script, you mean a unix shell script? > One challenge > is that you don't quite know how many time to run pdflatex. I guess usually > pdflatex, bibtext, pdflatex, pdflatex would work. > > Yes, this is what I meant, and the sequence you listed is what I would use. I don't know if it will work in 100% of all cases, but at worst you should have the .lyx and .tex files saved (and a LaTeX log file indicating why compilation failed), or maybe a PDF file with those annoying question marks where you were hoping for cross-references.
Re: Automatic save of LaTeX
Paul A. Rubin msu.edu> writes: > > Another possible approach is to define a new file format (Tools | File > Handling | File Formats) and a new converter (Tools | File Handling | > Converters) from LaTeX (pdflatex) to the new format. In the "Converter:" > field, supply the name of a script that first archives the .tex file, then > runs pdflatex (and bibtex?) against it, then archives the .pdf file > somewhere. Then you just have to export to the new format in the command > sequence (after saving the buffer). > > This sounds a little challenging. By script, you mean a unix shell script? One challenge is that you don't quite know how many time to run pdflatex. I guess usually pdflatex, bibtext, pdflatex, pdflatex would work.
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: > It seems I can only run one of the exports. Too bad. My idea > was that if you always save pdf and latex, you can > view the pdf on platforms that do not have LyX, and > edit the LaTeX. My main usage scenario would be > an iPad, but it could also apply if you use a computer > that does not have LyX installed. Another possible approach is to define a new file format (Tools | File Handling | File Formats) and a new converter (Tools | File Handling | Converters) from LaTeX (pdflatex) to the new format. In the "Converter:" field, supply the name of a script that first archives the .tex file, then runs pdflatex (and bibtex?) against it, then archives the .pdf file somewhere. Then you just have to export to the new format in the command sequence (after saving the buffer).
Re: Automatic save of LaTeX
Scott Kostyshak lyx.org> writes: > I think this issue might be the one that you're running into: > http://www.lyx.org/trac/ticket/8338 Looking at this ticket and the comments, it seems it the same kind of problem I run into. The exports run in parallel. It then makes sense that my iMac, which has a slower disk, gives more problems. It seems I can only run one of the exports. Too bad. My idea was that if you always save pdf and latex, you can view the pdf on platforms that do not have LyX, and edit the LaTeX. My main usage scenario would be an iPad, but it could also apply if you use a computer that does not have LyX installed.
Re: Automatic save of LaTeX
On 04/06/2016 06:12 PM, Anders Host-Madsen wrote: Update. If I run command-sequence buffer-write; buffer-export pdf2; buffer-export pdflatex It sometimes make LyX hang. If I run command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 sometimes the pdf export doesn't happen. So, neither quite work. I have a strong feeling it has to do with how long the commands take to run. On my iMac, which has a slow spinning HD, I get more trouble than on my MacBook, which has an SSD. I would think that the second sequence would have the least trouble with LyX not waiting for a command to finish, since the first two commands are (I thought) internal to LyX itself. The pdf generation calls external programs, LaTeX of course, then something like dvipdf, so once it's in the pipeline sometimes the shell might think the command is complete and then let LyX run the next process. That may cause the hang you mentioned, but does not explain the problem with the second sequence. -- David L. Johnson Department of Mathematics Lehigh University
Re: Automatic save of LaTeX
Update. If I run command-sequence buffer-write; buffer-export pdf2; buffer-export pdflatex It sometimes make LyX hang. If I run command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 sometimes the pdf export doesn't happen. So, neither quite work. I have a strong feeling it has to do with how long the commands take to run. On my iMac, which has a slow spinning HD, I get more trouble than on my MacBook, which has an SSD.
Re: Automatic save of LaTeX
Gordon Cooper kinect.co.nz> writes: > > > On 07/04/16 02:18, David L. Johnson wrote: > > I notice that, when I export repeatedly to pdf, the command will > > actually run and the pdf will not update unless the buffer has been > > changed. So that's probably why your pdf doesn't always run --- you > > have to change the document, then it will all run. > I can confirm that, happens here too. > > Gordon. > Tauranga N.Z. > > As said, that is not the problem. I change the document. Then sometimes, it exports to pdf, sometimes not. But it SEEMS (I haven't tried enough times yet) that if I change the order, it always executes all three commands (assuming the document is changed). So, if I use command-sequence buffer-write; buffer-export pdf2; buffer-export pdflatex it seems it always runs all three commands. But if I use command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 it seems it sometimes does not run the export to pdf. Odd.
Re: Automatic save of LaTeX
On 07/04/16 02:18, David L. Johnson wrote: I notice that, when I export repeatedly to pdf, the command will actually run and the pdf will not update unless the buffer has been changed. So that's probably why your pdf doesn't always run --- you have to change the document, then it will all run. I can confirm that, happens here too. Gordon. Tauranga N.Z.
Re: Automatic save of LaTeX
> I notice that, when I export repeatedly to pdf, the command will > actually run and the pdf will not update unless the buffer has been > changed. So that's probably why your pdf doesn't always run --- you > have to change the document, then it will all run. > No, that's not the issue. I do change the lyx file. If there is any pattern, then it seems like it only runs every second time. So, I change the lyx file, it doesn't convert to pdf. Then I make a trivial change, say inserting a space somewhere, run it again, and then it will save the pdf.
Re: Automatic save of LaTeX
I would probably log in from the iPad with vssh, run something like lyx -f -e pdflatex filename.lyx or a variation of this using make and scp the resulting thing onto the iPad. Point being, however, that I like to have a know state and not dump automatically with overwrite issues and all. On the other hand I must also confess that I can't do real work on the iPad, andif I want/need to do real work on the road, I always pull the netbook out of the backpack. For synchronization purposes I use Unison: http://www.cis.upenn.edu/~bcpierce/unison/docs.html Very, very cool. el On 2016-04-05 15:58, Anders Host-Madsen wrote: > Dr Eberhard Lisse lisse.NA> writes: > >> >> What on earth for? >> > > There are several reasons. But a main reason is that > I would like to be able to edit my documents on my iPad. LaTeX > exists, but not LyX. I can edit the latex, and then copy > the changes back to LyX. But that does require I have > access to the latex version. It often happens I have > my iPad with me, I unexpectedly get some extra time > and would like to do some work -- but then I don't have > the latex version of the document I'm working on. > >
Re: Automatic save of LaTeX
On 04/06/2016 10:05 AM, Anders Host-Madsen wrote: Anders Host-Madsen yahoo.com> writes: I can only say that so far it works for me. I assigned command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 to a key (control-command-S), and it works as intended. I'm using a mac. I do have one issue, though. Sometimes the third part is not executed, so the updated pdf is not saved. I don't see the pattern in when it's executed, and when it's not. I notice that, when I export repeatedly to pdf, the command will actually run and the pdf will not update unless the buffer has been changed. So that's probably why your pdf doesn't always run --- you have to change the document, then it will all run. -- David L. Johnson Department of Mathematics Lehigh University
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: > > I can only say that so far it works for me. I assigned > > command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 > > to a key (control-command-S), and it works as intended. I'm using a mac. > > I do have one issue, though. Sometimes the third part is not executed, so the updated pdf is not saved. I don't see the pattern in when it's executed, and when it's not.
Re: Automatic save of LaTeX
Scott Kostyshak lyx.org> writes: > > On Wed, Apr 06, 2016 at 11:19:06AM +1200, Andrew Parsloe wrote: > > On 6/04/2016 8:55 a.m., Anders Host-Madsen wrote: > > >Thanks, that works. I see I can use the command-sequence to combine > > >the commands. So, now it works. > > I'm interested to know whether this really does work. In the past when I've > > tried to use command-sequence with export or save operations it has run into > > problems with threaded code -- an export or save is not completed before the > > next command in the sequence is initiated. > > I think this issue might be the one that you're running into: > http://www.lyx.org/trac/ticket/8338 > > Also note these posts: > http://tex.stackexchange.com/questions/71110/can-lyx-automatically-save-the-pdf-output-in-the- same-folder/71212#71212 > http://tex.stackexchange.com/questions/89561/shortcut-for-export-pdf-on-lyx/89562#89562 > > Scott > I can only say that so far it works for me. I assigned command-sequence buffer-write; buffer-export pdflatex; buffer-export pdf2 to a key (control-command-S), and it works as intended. I'm using a mac.
Re: Automatic save of LaTeX
On Wed, Apr 06, 2016 at 11:19:06AM +1200, Andrew Parsloe wrote: > On 6/04/2016 8:55 a.m., Anders Host-Madsen wrote: > >Thanks, that works. I see I can use the command-sequence to combine > >the commands. So, now it works. > I'm interested to know whether this really does work. In the past when I've > tried to use command-sequence with export or save operations it has run into > problems with threaded code -- an export or save is not completed before the > next command in the sequence is initiated. I think this issue might be the one that you're running into: http://www.lyx.org/trac/ticket/8338 Also note these posts: http://tex.stackexchange.com/questions/71110/can-lyx-automatically-save-the-pdf-output-in-the-same-folder/71212#71212 http://tex.stackexchange.com/questions/89561/shortcut-for-export-pdf-on-lyx/89562#89562 Scott signature.asc Description: PGP signature
Re: Automatic save of LaTeX
Andrew Parsloe clear.net.nz> writes: > I'm interested to know whether this really does work. In the past when > I've tried to use command-sequence with export or save operations it has > run into problems with threaded code -- an export or save is not > completed before the next command in the sequence is initiated. > > Andrew I have only used it a few times so far, and it seems to work. If the first command, buffer-write, fails because there are no changes, the rest does not run either. But in this case that is clearly desirable.
Re: Automatic save of LaTeX
On 6/04/2016 8:55 a.m., Anders Host-Madsen wrote: Thanks, that works. I see I can use the command-sequence to combine the commands. So, now it works. I'm interested to know whether this really does work. In the past when I've tried to use command-sequence with export or save operations it has run into problems with threaded code -- an export or save is not completed before the next command in the sequence is initiated. Andrew --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Re: Automatic save of LaTeX
Thanks, that works. I see I can use the command-sequence to combine the commands. So, now it works.
Re: Automatic save of LaTeX
Paul A. Rubin msu.edu> writes: > > Anders Host-Madsen yahoo.com> writes: > > > > > Is there a way to make LyX automatically save the LaTeX version of a > > document > > every time the LyX document is saved? > > > > You can write a custom macro that chains the buffer-write and buffer-export > LFUNs and bind it to some key combination. Then you need to remember to use > that key combo whenever you save your file. You will need to specify an > export format (e.g., pdflatex) in the buffer-export function. The LFUNs are > detailed in Help > LyX Functions. > > Paul > > Thanks. That would work for me. I checked the LFUNs, and I see how I can make each work individually. But how do I combine them? That is, how do I write a macro? I only see something about math macros.
Re: Automatic save of LaTeX
Anders Host-Madsen yahoo.com> writes: > > Is there a way to make LyX automatically save the LaTeX version of a document > every time the LyX document is saved? > You can write a custom macro that chains the buffer-write and buffer-export LFUNs and bind it to some key combination. Then you need to remember to use that key combo whenever you save your file. You will need to specify an export format (e.g., pdflatex) in the buffer-export function. The LFUNs are detailed in Help > LyX Functions. Paul
Re: Automatic save of LaTeX
Dr Eberhard Lisse lisse.NA> writes: > > What on earth for? > There are several reasons. But a main reason is that I would like to be able to edit my documents on my iPad. LaTeX exists, but not LyX. I can edit the latex, and then copy the changes back to LyX. But that does require I have access to the latex version. It often happens I have my iPad with me, I unexpectedly get some extra time and would like to do some work -- but then I don't have the latex version of the document I'm working on.
Re: Automatic save of LaTeX
What on earth for? el On 2016-04-04 20:47, Anders Host-Madsen wrote: > Is there a way to make LyX automatically save the LaTeX version of a document > every time the LyX document is saved? > >