Discussion:
LyX 2.0, inverse & forward search, Sumatra PDF
econo phd
2011-05-03 10:52:00 UTC
Permalink
Hello,
I have been using LyX quite for a while. Thanks to all who contributed. LyX
2 is great.
But I had difficulty in configuring and using inverse and forward-search
features for SumatraPDF.

I developed my own solution, perhaps you might be interested.

1. I was annoyed by command windows popoping up everytime i use inverse
search from sumatra pdf to lyx. So I have two compiled exe files for this.

- lyxeditor.exe does similar to lyxeditor.bat described in documentation
- lyxswitch.exe switchs correctly back to lyx after inverse search

2. Configuring lyx for inverse and forward search is quite cumbersome, for
some reason inverse search was not working since sumatrapdf was called from
"C:\Program Files\Lyx20\bin".

- I added SumatraPDF folder in LyX:Preferences:Paths:PATH prefix
- SumatraView.bat as PDF viewer under file formats, pdf (pdflatex) as
viewver

All files are attahced and below you can find codes.
Inverse and Forward search works seamlessly. If you have a large screen, put
lyx on left and sumatra on right side, it is great to work.
You should put all files under your default SumatraPDF folder

codes:

1. SumatraView.bat (for configuring inverse search and making forward search
work correctly)

start "" /D"%~dp1" /B "SumatraPDF.exe" -reuse-instance -inverse-search
"lyxeditor.exe %%f %%l" %~nx1

2. lyxeditor.exe (lyxeditor.ahk, compiled using http://www.autohotkey.com/)

Run %comspec% /q /c echo LYXCMD:revdvi:server-goto-file-row:%1% %2%>
\\.\pipe\lyxpipe.in&&type \\.\pipe\lyxpipe.out, , Hide
SetTitleMatchMode, 2
Loop, Parse, 1, \
{
IfInString, A_LoopField, .tex
{
StringReplace, lyx, A_LoopField, .tex , .lyx
IfWinExist, %lyx%
WinActivate
}
}

2. lyxswitch.exe (lyxswitch.ahk, compiled using http://www.autohotkey.com/)

SetTitleMatchMode, 2

Loop, Parse, 1, \
{
IfInString, A_LoopField, .tex
{
StringReplace, lyx, A_LoopField, .tex , .lyx
IfWinExist, %lyx%
WinActivate ; use the window found above
}
}

Regards,
econophd
Daniel Conrado
2011-05-29 04:25:32 UTC
Permalink
Hello,I have been using LyX quite for a while. Thanks to all who contributed.
LyX 2 is great.But I had difficulty in configuring and using inverse and
forward-search features for SumatraPDF.I developed my own solution, perhaps you
might be interested.1. I was annoyed by command windows popoping up everytime i
use inverse search from sumatra pdf to lyx. So I have two compiled exe files for
this.
lyxeditor.exe does similar to lyxeditor.bat described in documentation
lyxswitch.exe switchs correctly back to lyx after inverse search
2. Configuring lyx for inverse and forward search is quite cumbersome, for
some reason inverse search was not working since sumatrapdf was called from
"C:\Program Files\Lyx20\bin".
I added SumatraPDF folder in LyX:Preferences:Paths:PATH prefix
SumatraView.bat as PDF viewer under file formats, pdf (pdflatex) as viewver
All files are attahced and below you can find codes.
Inverse and Forward search works seamlessly. If you have a large screen, put
lyx on left and sumatra on right side, it is great to work.You should put all
1. SumatraView.bat (for configuring inverse search and making forward search
work correctly)start "" /D"%~dp1" /B "SumatraPDF.exe" -reuse-instance -inverse-
search "lyxeditor.exe %%f %%l" %~nx12. lyxeditor.exe (lyxeditor.ahk, compiled
using http://www.autohotkey.com/)Run %comspec% /q /c echo LYXCMD:revdvi:server-
goto-file-row:%1% %2%> \\.\pipe\lyxpipe.in&&type \\.\pipe\lyxpipe.out, ,
HideSetTitleMatchMode, 2Loop, Parse, 1, \{    IfInString, A_LoopField, .tex   
{        StringReplace, lyx, A_LoopField, .tex , .lyx        IfWinExist,
%lyx%            WinActivate    }}2. lyxswitch.exe (lyxswitch.ahk, compiled
using http://www.autohotkey.com/)SetTitleMatchMode, 2Loop, Parse, 1, \{   
IfInString, A_LoopField, .tex    {        StringReplace, lyx, A_LoopField, .tex
, .lyx        IfWinExist, %lyx%            WinActivate ; use the window found
above    }}Regards,econophd
Attachment (LyX_SumatraPDF.7z): application/octet-stream, 213 KiB
Hello,

Thank you! It worked fine here!

But, there is a small problem with lyxeditor.
It does not work for lines whose number are less than 10.
but I solved it. You just have to put the whole string that has to be sent to
the lyxpipe in parentheses, like that:

Run %comspec% /q /c (echo LYXCMD:revdvi:server-goto-file-row:%1% %2%)>
\\.\pipe\lyxpipe.in&&type \\.\pipe\lyxpipe.out, , Hide

that's it.
thank's again.
best regards,
--Daniel
dc
2011-09-08 16:07:52 UTC
Permalink
Post by econo phd
2. Configuring lyx for inverse and forward search is quite cumbersome, for
some reason inverse search was not working since sumatrapdf was called from "C:
\Program Files\Lyx20\bin".
this was happening to me too with lyx 2.0.0 on windows vista
Post by econo phd
I added SumatraPDF folder in LyX:Preferences:Paths:PATH prefix
DId this
C:\Program Files\SumatraPDF
Post by econo phd
SumatraView.bat as PDF viewer under file formats, pdf (pdflatex) as viewver
this confuses me. First of all, I need to use pdf (xetex)
but anyhow, if I put your files in the directory above, and use for FORMAT :
pdf (xetex)
and for VIEWER:
"C:\Program Files\SumatraPDF\SumatraView.bat"

and
CMCDDE SUMATRA control [ForwardSearch(\"$$o\",\"$$t\",$$n,0,0,1)]
as my tools:preferences:output:general:Forward search:pdf command

and then I reconfigure

what happens is that
when I view the file as pdf (xetex)
Sumatra.bat runs
00:54:37.609: "C:\Program Files\SumatraPDF\SumatraView.bat" "C:/Users/HP_User/
AppData/Local/Temp/lyx_tmpdir.Hp5416/lyx_tmpbuf2/Mybook.version.2.pdf"
00:54:37.674: Successful preview of format: pdf4

and opens the pdf
and the options for the pdf show
lyxeditor.exe %f %l
as my return editor

but neither forward search or reverse synch work.

If I forward search it gives me
00:56:23.928: CMCDDE SUMATRA control [ForwardSearch
("""Mybook.version.2.pdf""","""Mybook.version.2.tex""",892,0,0,1)]
00:56:23.937: (forward-search)

but it doesn't do anything.

reverse sync /double click tells me "no synchronization file present"

this was with document :settings: output: synchronize: turned off.


if I turn that on with
\synctex=-1
as my macro

reconfigure
restart

and all other settings as above, and redo view pdf (xetex)

and:
same as above.
Xi Zhang
2012-03-30 08:58:30 UTC
Permalink
Hello,I have been using LyX quite for a while. Thanks to all who
contributed. LyX 2 is great.But I had difficulty in configuring and using
inverse and forward-search features for SumatraPDF.I developed my own
solution, perhaps you might be interested.1. I was annoyed by command windows
popoping up everytime i use inverse search from sumatra pdf to lyx. So I have
two compiled exe files for this.
lyxeditor.exe does similar to lyxeditor.bat described in documentation
lyxswitch.exe switchs correctly back to lyx after inverse search
2. Configuring lyx for inverse and forward search is quite cumbersome, for
some reason inverse search was not working since sumatrapdf was called
from "C:\Program Files\Lyx20\bin".
I added SumatraPDF folder in LyX:Preferences:Paths:PATH prefix
SumatraView.bat as PDF viewer under file formats, pdf (pdflatex) as viewver
All files are attahced and below you can find codes.
Inverse and Forward search works seamlessly. If you have a large screen, put
lyx on left and sumatra on right side, it is great to work.You should put all
1. SumatraView.bat (for configuring inverse search and making forward search
work correctly)start "" /D"%~dp1" /B "SumatraPDF.exe" -reuse-instance -inverse-
search "lyxeditor.exe %%f %%l" %~nx12. lyxeditor.exe (lyxeditor.ahk, compiled
using http://www.autohotkey.com/)Run %comspec% /q /c echo LYXCMD:revdvi:server-
goto-file-row:%1% %2%> \\.\pipe\lyxpipe.in&&type \\.\pipe\lyxpipe.out, ,
HideSetTitleMatchMode, 2Loop, Parse, 1, \{    IfInString, A_LoopField, .tex   
{        StringReplace, lyx, A_LoopField, .tex , .lyx        IfWinExist, %
lyx%            WinActivate    }}2. lyxswitch.exe (lyxswitch.ahk, compiled
using http://www.autohotkey.com/)SetTitleMatchMode, 2Loop, Parse, 1, \{   
IfInString, A_LoopField, .tex    {        StringReplace, lyx,
A_LoopField, .tex , .lyx        IfWinExist, %lyx%            WinActivate ; use
the window found above    }}Regards,econophd
Attachment (LyX_SumatraPDF.7z): application/octet-stream, 213 KiB
Hi,

I am trying to do the same thing. Follwing
http://wiki.lyx.org/LyX/SyncTeX#toc2, the inverse part work fine but the the
positive part cannnot work. Now I understand that it is due to the fact that I
don't have CMCDDE.exe.

Follwing you way, every thing works fine! Thank you very much!

Also, I am wondering if in the positive part, the highlight process can last
longer?

Best, Xi

Loading...