...create a tightly cropped picture?

GoodCrop1If you've got a figure that needs to be cropped then pdfcrop or Briss are great tools as I mentioned on the LaTeX page. But if you're creating your own picture, you can cut out the extra step using the standalone package. As the documentation indicates, all you have to do is make sure that the document is using the standalone document class (rather than typical arguments of article or book). The picture is then cropped to the content plus a default border. The border can be adjusted as an option of documentclass by either

  • border=< length (all sides)>
  • border={< length (left/right) > <length (bottom/top)>}
  • border={<length (left)><length (bottom)><length (right)><length (top)}

So, for example

\documentclass[border=12pt]{standalone}

will give a 12 pt border for each side around the figure while

\documentclass[border={4pt 8pt}]{standalone}

puts 4pts of space on the left and right but 8pt above and below the picture. Finally,

\documentclass[border={4pt 8pt 12pt 24pt}]{standalone}

will put 4pts of space on the left, 8pt below, 12pt to the right, and 24pt above.

Compare the border of the output below, where the first line is

\documentclass[tikz=true,border={0pt 2pt 2pt 8pt}]{standalone}

with the picture at the top of this page.

GoodCrop2There are other options, such as tikz, pstricks, and beamer (see the documentation for more details. I used tikz=true because tikz was used in creating the diagram. If you have some sort of image conversion program installed on your computer then there's a convert option to convert the output to picture formats such as jpg, png, and more.

Here's a sample file you can experiment: GoodCrop (.tex)

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code