CaseLeaf

Handbook / The `source` command

The source command

A typeset document has a line that looks wrong, and you need to find the exact place in the source it came from.

Finds where a point on the page came from in the document's own source. It needs a SyncTeX map, the file a LaTeX build leaves beside the PDF when it is built with -synctex=1, or one given with --map. Reach for it when a typeset line is wrong and reading the source by eye would mean guessing which paragraph produced it.

How you run it

caseleaf source report.pdf --page 1 --at 72,540 --map reviewed.pdf

What each part means

In full, every part it will take:

caseleaf source <file> --page <n> --at x,y [--map <file>]
part what it is for
<file> The PDF to work on, as a path, such as report.pdf beside you, or the full path to it. It is read and not written.
--page Which sheet, counting from 1, so --page 4 is the fourth sheet as it sits in the file, whatever number is printed on it. This command needs it.
--at The point to ask about, as x,y in points from the foot of the sheet, for example 72,700. What comes back is the file and line of source that drew it there.
--map A SyncTeX map, as a path, when it is not beside the document, such as report.synctex.gz. It is what lets an answer name the line of source that drew something.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "at" : [
    72,
    540
  ],
  "found" : false,
  "page" : 1
}

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "source" on "/path/to/report.pdf" ¬
        options "--page 1 --at 72,540 --map reviewed.pdf"
end tell

All the commands · Asking from a script · Contents