macosskim

Skim displayline only bring the pdf in foreground


I am trying to display a line by running the following command from iTerm2 (macos 14.6.1, Skim 1.7.4):

/Applications/Skim.app/Contents/SharedSupport/displayline 2 example.pdf 

But other than bringing the .pdf in foreground nothing happens. I cannot see any highlight or anything to indicate line 2. What can I do?


Solution

  • Displayline is a LaTeX enhancement module for Skim, which is designed for cross platform PDFLaTeX generated PDF's that have an attendant synctex file. Thus works in Okular, Acrobat, Skim, etc.

    From a programming point of view you do not have to use LaTeX to write a synctex file but it is not easy unless you research the format. It is based on rectangles and magnification levels.

    SyncTeX Version:1
    Input:1:./sync.tex
    Input:2:/usr/local/texlive/2017/texmf-dist/tex/latex/base/article.cls
    Input:3:/usr/local/texlive/2017/texmf-dist/tex/latex/base/size10.clo
    Output:pdf
    Magnification:1000
    Unit:1
    X Offset:0
    Y Offset:0
    Content:
    !305
    {1
    [1,25:4736286,46220574:26673152,41484288,0
    [1,25:8799518,46220574:22609920,40435712,0
    [1,25:8799518,6571294:22609920,786432,0
    h1,25:8799518,6571294:22609920,0,0
    ]
    

    At the time of compilation there should be at least three files in the same folder.

    enter image description here

    In an editor the TeX file line will have a number. Here it is Line 9

    enter image description here

    Thus when we call a tex enabled PDF viewer with that number (9) that line will be area highlighted by virtue of a look-up in the attendant .synctex file with rectangles.

    Note as PDF does not have line numbers TeX line 9 is the first area in this PDF.

    enter image description here

    Likewise when we click in the PDF that line (here line 1 ABC) will be translated to the tex editor line number so in this example 21.

    enter image description here

    The system is contra[r]Y to PDF system of lower left origin. Thus is top left orientated. So if we halve the magnification, the highlight will be half size and towards top left of a page.

    enter image description here

    To expand on the Programming aspect you can without LaTeX, program a simplified surrogate file. So if you were to print this Q&A we can add a sidecar file like this.

    SyncTeX Version:1
    Input:1:./example.txt
    Output:pdf
    Magnification:1000
    Unit:66667
    X Offset:0
    Y Offset:0
    Content:
    !112
    {1
    (1,1:36,73:440,30,0)
    (1,2:36,90:220,10,0)
    !50
    }1
    !7
    {2
    (1,3:36,73:440,30,0)
    (1,4:36,90:220,10,0)
    !48
    }2
    Postamble:
    Count:4
    !26
    Post scriptum:
    

    Then to highlight line 2 we call it as such. enter image description here

    The above sample shows an adapted scaling to suite whole "Point" sizes. However you can alter (as desired) for less than points, by increasing the low values and alter magnification or units.

    You can read the specification as to what those tokens mean. But to start you off, my untested abuse is based on pages {1...}1 {2...}2. The byte offset length pointers are such as !7 (between the 2 pages) includes the previous !50 which is the byte length from the previous !112 etc. the (1,3 rectangle is xxx,yyy:www,hhh,ddd at lower left corner, in page 2, from file 1, source line 3. See it is easy to parse!