Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to connect GEdit and xdvi. I don't use the gedit LaTeX plugin as I don't use LaTeX, but plain TeX. Well, for the inverse search I compile the TeX file with the "external tools" plugin and the following code:

#!/bin/bash
TEXFILE=$GEDIT_CURRENT_DOCUMENT_NAME
DVIFILE=${TEXFILE/%.*/.dvi}
LOGFILE=${TEXFILE/%.*/.log}
if pdftex -output-format=dvi -src-specials -halt-on-error $TEXFILE; then
    xdvi -editor gedit $DVIFILE
    else gedit $LOGFILE
    fi

and the inverse search works quite well.

BUT I'm not able to set the direct search correctly. I'm trying the following code

#!/bin/bash
TEXFILE=$GEDIT_CURRENT_DOCUMENT_NAME
DVIFILE=${TEXFILE/%.*/.dvi}
xdvi -sourceposition $GEDIT_CURRENT_LINE_NUMBER $DVIFILE

but it doesn't work. The error message is "No reference to source file "test.dvi" in DVI file."

Where is the fault?

share|improve this question
1  
If you are happy to use Evince rather then xdvi you can checkout askubuntu.com/q/68015/19490 –  N.N. Aug 6 '12 at 16:06
    
@N.N. Sorry, it doesn't works. Thanks anyway. –  Jean Baldraque Aug 6 '12 at 20:15

1 Answer 1

Jean, although I don't use gedit, it's a very useful editor, readily available in GNU/Linux, that it's underrated to say the least.

Second edit

I couldn't get it to work. The first time around, the file hadn't compiled from within the editor. So, I wrongly assumed that forward search was working. To top it off, I always see the error, right after posting an answer, so it didn't surprise me.

In the end I'm disappointed with it. I'm just editing the answer, in case someone has a solution over this problem.

The parameter to -sourceposition "nn <ref>" had to be hard coded into it, juxtaposing perhaps, the reason that lies in your question in the first place. Moreover, better not to compile another file from within the editor, or else the xdvi window from the previous one, would take priority. (But I'm sure you've come across this issue before).

So as you know, to call a special reference, from within the document, input srctex.sty must be loaded. And let's say, for the sake of posting an example, that the command\special is invoked, three times throughout the document: in the first, and last pages. So you would have a \special{src:blue}, a \special{src:red} and a \special{src:black}


input srctex.sty

\input linden

\vfill\break
\special{src:blue}
\input lorem 

\vfill\break

\input cervantes-es

\vfill\break     

\input zapf

\special{src:red}

\vfil\break

\special{src:black}  

\bye

With that file in place, it doesn't really matter whether you decide to run it from the terminal or from gedit, as long as it jumps, wherever it is you want it to.

$: xdvi -sourceposition "n:blue" <file>

Or in external tools

enter image description here

First edit

I noticed in the code you posted, that the variable does not need to precede the call to the dvi file. As you know, this is already defined in the options of the the external tools plugin.

The following is the list from https://wiki.gnome.org/action/show/Apps/Gedit/Plugins/ExternalTools

enter image description here

You'd need to omit the $GEDIT_CURRENT_LINE_NUMBER from the above code, since the current line - where you would rather have, the direct search to be performed - might as well, be selected from the aforementioned options.

enter image description here

The following should work:

#!/bin/bash
TEXFILE=$GEDIT_CURRENT_DOCUMENT_NAME
DVIFILE=${TEXFILE/%.*/.dvi}
xdvi -sourceposition $DVIFILE 

if pdftex -output-format=dvi -src-specials -halt-on-error $TEXFILE; then
xdvi -editor gedit $DVIFILE
else gedit $LOGFILE
fi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.