[OS X TeX] texshop and preview

Richard Koch koch at math.uoregon.edu
Sun May 23 16:36:36 EDT 2010


Folks,

I wrote this last night, but then sent the message only to myself. Now I'm sending it to the
list, and adding a paragraph to explain Herb's discovery this morning.

a) Ross Moore rightly suggested that it would be useful to look at the code and see what each program
is actually doing with a pdf file. In the case of TeXShop, here is the essential code:

		PDFDocument	*pdfDoc;

	if ([self doReleaseDocument]) {
		pdfDoc = [[[PDFDocument alloc] initWithURL: [NSURL fileURLWithPath: imagePath]] autorelease]; 
		[self setDocument: pdfDoc];
	} else {
		...
	}
		
	[myPDFWindow makeKeyAndOrderFront: self];

I left out some lines which deal with displaying the total number of pages in the document in the
GUI, but the essential story is here.

Let me translate. PDFDocument is a class in PDFKit which obtains and organizes data from a pdf file;
the code displayed above belongs to a PDFView class ---  a PDFKit class which displays PDF data. The lines

	if ( [self doReleaseDocument]) {
		...
	else
		...

say "if we are running on Leopard, everything will work fine, but otherwise we have to do some
fancy footwork to avoid PDFKit bugs"; this explains why the TeXShop web page says
"System 10.5 or Higher Strongly Recommended".

So essentially the above code says

	tell PDFKit to create a PDFDocument class from the pdf file
	give that PDFDocument to the PDFView
	tell the window to display itself

There is no code to determine page size, bounding boxes, media boxes, or anything else. All of
that is handled by PDFKit. TeXShop does all sorts of things, but it doesn't dig into the pdf file
in any way.

If somebody is cutting off the top of that circle, it isn't me.


Addition: This morning, Herb discovered that the top of the circle is not cut off in TeXShop if viewed 
with the magnifying glass. The TeXShop code for the magnifying glass occurs in an entirely different
place, and is done by manipulating the PDFView's documentView bounds and redrawing. So one
of the bounding rectangles which PDFKit picked up from the pdf file has been resized, allowing the
underlying pdf to show through. 


b) Usually I run TeXShop with magnification set to "Fit To Window." In the key example below, this gives a large
circle, cut off at the top. But if you set magnification to "Actual Size", you'll see that the circle is
very small. it is fun to magnify the circle by changing all numbers below to numbers ten times as large.
Switching back to "Fit To Window", you'll immediately see that TeXShop --- er, PDFKit --- does the right thing.

So whatever is going on is an incorrect clip box, or some box, off by a few pixels. I suspect one of
tikz, the geometry package, and pdftex is bounding the dimensions of one of the boxes.This rounding is
visible to us because the image is subsequently magnified a lot.




c) Direct inspection of the pdf file shows lots of compressed information. It would be nice to have that file
in uncompressed form. Google suggests that a free program named pdftk can do that, but the version of
the program I found for OS X couldn't handle PDF-1.5 files. Can anyone uncompress that pdf file? Even
better, remove the line which inserts text, typeset, and then uncompress, hoping for a pdf file as short
and simple as possible.


Dick Koch




>>> The following example was posted in MacOSX TeX mailing list
>>> 
>>> \documentclass{article}
>>> \usepackage{tikz}
>>> \usepackage[papersize={51pt,51pt},margin=.5pt,centering]{geometry}
>>> \begin{document}
>>> \parindent 0pt
>>> \begin{tikzpicture}
>>> \draw[line width=.5pt] (0,0) circle (24.75pt);
>>> \draw (0,0) node{24.75pt};
>>> \end{tikzpicture}
>>> \end{document}
> 





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-tex/attachments/20100523/5dba969c/attachment.html>


More information about the MacOSX-TeX mailing list