Once I posted a simple LaTeX code and the associated PDF output when I asked a question. Few minutes later some nice person edited my post by cropping the empty area of the PDF document. Since then I read the FAQ, went through all 88 support questions to learn how to do it without luck. Hence the question. Am I overlooking something simple?
-
1related question: tex.stackexchange.com/questions/11866/…– doncherryCommented Sep 29, 2011 at 22:32
-
1I was going to say, "Isn't this actually a question for the main site, and isn't it already answered there?" but then I read the answers and learnt about imgur accepting PDFs - which I didn't already know - so agree that this should stay as a meta question! In fact, with a little polishing it could serve as an FAQ. Would you mind if we tidied it (and the answers) a little to do that? (If not, we can just ask a new question.)– Andrew StaceyCommented Sep 30, 2011 at 7:47
-
1Related question: here mentions several alternatives, some not mentioned below.– DJPCommented Sep 30, 2011 at 16:32
-
@AndrewStacey: If your question is directed to me, then I do not mind. Please feel free to polish it and make it part of the faq.– SonyCommented Oct 1, 2011 at 13:35
9 Answers
On Mac OS, Preview.app has a crop tool. I usually just crop the pdf and then save as PNG. Since Preview is my default PDF viewer, it's only a few clicks/keystrokes to do so.
Another way to crop an image in someone's question is to use the imgur
website that hosts the pictures for TeX.sx:
- copy the image URL of the image you want to edit (e.g. right-click on the image, click
Copy Image Location
, in Firefox) - go to http://imgur.com/
- paste the URL
- click
Edit
- draw a rectangle around the desired area
- click
Save
- copy the URL of the edited image that's presented to you
- in the question, insert a new image, paste the URL
-
2Apparently there's a couple of tools for imgur – web browser addons, bash scripts, etc. – at imgur.com/tools– N.N.Commented Sep 30, 2011 at 6:44
pdfcrop
is very useful for cropping PDF files, capable of automatically removing all white margins.
However, as you cannot directly embed PDF images, I guess you mean PNG images or other bitmap formats. In this case I assume, it's done using any picture editor such as GIMP (which I use), just line N.N. said.
-
1This is interesting. I posted a pdf output generated by TeXShop without converting to a PNG to tex.stackexchange.– SonyCommented Sep 29, 2011 at 22:51
-
5@Sony: ok, there's an automatic conversion of PDF to PNG when posting images. So
pdfcrop
is still a recommendation, and bitmap editors too.– Stefan Kottwitz ModCommented Sep 29, 2011 at 22:56 -
Thank you very much. I will be posting a question soon that I have been postponing to ask, because I did not know how to crop a pdf. Now I know. Thanks again.– SonyCommented Sep 29, 2011 at 23:19
I use a screenshot tool called Shutter under Ubuntu Linux which allows making screenshots by manual selection. I open the PDF with Acrobat Reader, start Shutter, click "Selection" and select the area I want. I configured it to place it as PNG in my /tmp
folder so I can easily access it in the image upload dialog of this site.
An alternative is to use the standalone
class for the LaTeX document which also creates a cropped PDF. Note that imgur is able to convert PDFs to PNGs by itself, however you don't have control over the used resolution, i.e. the image might be quite small.
Recent editions of Windows (Vista & 7) is shipped with the Snipping Tool application that allows you to capture parts of the screen through a marquee. Saving to PNG (or other image formats) is done after capturing the screen selection, without having to use other external image manipulation software applications.
Since February 2013, users have been able to copy-and-paste images directly into posts via the regular "Insert image" (or Ctrl+G) tool. This skips saving content to file for uploading, which is much easier and faster.
They probably saved the picture of the pdf output, opened it in an image editor, cropped it and finally replaced the picture in your question with it.
You could also directly take a cropped screenshot, using an appropriate tool. E.g. on Gnome/Linux you can use gnome-screenshot --area
to select an arbitrary rectangular part of the screen to export as a picture.
For ConTeXt examples, I normally add
\startTEXpage
....
\stopTEXpage
around the relevant code. This generates a cropped pdf page.
Within the TeXniverse itself there's also the preview
package and Martin's standalone
class (which, used on its own, uses preview
in an easy automagic way, although this isn't the main purpose of the associated package).