Hot answers tagged

255

You can crop your image with graphicx \documentclass{article} \usepackage{graphicx} \begin{document} % trim from left edge \includegraphics[trim={5cm 0 0 0},clip]{example-image-a} % trim from right edge \includegraphics[trim={0 0 5cm 0},clip]{example-image-a} \end{document} Use the trim option, which takes four space separated values. trim={<left>...


79

You can crop/trim a pdf when including it using the trim=left botm right top. Full example: \begin{figure}[htbp] \centering \includegraphics[clip, trim=0.5cm 11cm 0.5cm 11cm, width=1.00\textwidth]{gfx/BI-yourfile.pdf} \caption{Title} \label{fig:somthing} \end{figure} Note: Figuring out how far to trim can take time. To speed things ...


30

You can use the border=<len> class option to increase the width of the border around the cropped output: \documentclass[border=1pt]{standalone}% http://ctan.org/pkg/standalone \begin{document} $2^5 = x_5 \times y^8$ \end{document} As in your case, the border around the image is not present in the PDF, it's from my screen capture. It is also possible ...


24

To clip 50% of the right of your image without using extra packages you can use a savebox to measure the natural size of the image first. This only required the graphicx package which is part of LaTeX itself and always installed. Note that all scaling/resizing is applied after the trimming. If you want the original image be scaled to 5cm width and then 50% ...


19

If the coordinates of the valuable parts in your PDF images is fixed, then the following method can be automated. Use the following template to trim or crop images and compile it with xelatex. You will get 2 pages, one for navigation and the other one is the cropped image. % cropping.tex \documentclass{article} \usepackage{pstricks} \usepackage{graphicx}...


17

To be able to crop a vector graphic reliably you must "print" it to see where the black dots are. "Printing" always involves a resolution: the black dots must have a positive size. pdfcrop uses the bbox device of ghostscript. According to the documentation of ghostscript the default resolution of this device is 4000 dpi. You can change this resolution ...


15

You do not need a cropped copy with a external program, only add some options to \includegraphics. This MWE show the same image twice (renamed to image.png) , with and without the useless background. Both images are inside a framed box to show the edges: \documentclass{article} \usepackage{graphicx} \begin{document} \section*{Original image} \fbox{\...


14

You have a couple of options with this "problem". You can use an external approach and trim the whitespace around the image. pdfcrop is capable of doing this and uses the following interface pdfcrop [options] <input[.pdf]> [output file] where [ ] denotes optional specifications. If your Dia-exported PDF image, (say) image.pdf, consists of entire ...


14

\includepdf accepts all the options that \includegraphics does; so trim=left bottom right top,clip should work (unless you're using XeLaTeX that, currently, doesn't support cropping). You have to compute the four dimensions, but probably left and right should be 0, while top and bottom depend on the document you have. Example (from your comment) \...


11

(Summarising the comments as an answer.) pdfTeX will work with px units, but you have to set these up appropriately using \pdfpxdimen. This is the physical width of one pixel, and has default value of 1 bp, meaning that images initially are assumed to be 72 dpi. \pdfpxdimen is a low-level dimen primitive, and so is best set using \dimexpr: \pdfpxdimen=\...


11

It is clearly a bug in the driver for package graphicx: pdftex.def: ok. dvips.def: ok for PostScript images, but clipping is not supported for bitmap images. xetex.def: Clipping is not supported at all. dvipdfm.def: The image is not trimmed, but distorted in the final area. dvipdfmx.def: The whole image is put in the final area without distortion, but empty ...


10

You can do this with pdfpages. The following example takes a two-up scan of a book, and crops and collates it to a one-up document. \documentclass[letterpaper]{minimal} \usepackage[pdftex,letterpaper]{geometry} \usepackage{pdfpages} \usepackage{ifthen} \newcounter{pg} \begin{document} \setcounter{pg}{1} %% my pdf file has 132 pages: %% my pdf file has size ...


10

Since you'd like to "...set margins from each direction, and the PDF is then cropped accordingly..." in order to "...control what portion of the included PDF is visible in the final document..." I would suggest you try Briss. It's easy to use and gives you much more control than pdfcrop.


10

In the terminology of the geometry package, the paper<*> parameters refer to the physical size of the sheets of paper the document will be printed on. The layout<*> parameters, by contrast, refer to the logical size of the "paper", which will (one hopes) be no larger than the physical size of the sheet of paper. (Put differently, with regard to ...


9

There are two questions here: 1) How to specify the page size. This is best done with the geometry package, which has good documentation. The key idea is that you only specify as many parameters as necessary, and geometry fills in the rest. For example, you could say \usepackage[twoside,papersize={7in,10in},margin=1in]{geometry} and have the text width ...


9

\documentclass[dvipsnames,10pt]{article} \usepackage [ a6paper, margin=5mm ] {geometry} \usepackage[table]{xcolor} \usepackage{longtable,array} \usepackage{marvosym} \usepackage{graphicx} \pagestyle{empty} \begin{document} \centering\sf \rowcolors{2}{Green!10}{Yellow!10} \begin{longtable}{*{4}{>{\scriptsize}c}} \rowcolor{Gray!20} \raisebox{-0.5pt}{\...


9

To expand on Ulrike's excellent answer: The reason this is only guaranteed after rendering the font to an actual pixel map is that there is, in principle, no obligatory relation between a glyph's ink and its bounding box. Here's an example; a lower-case 'm' from URW Nimbus Sans: The left and right sidebearings (the space between the ink and the bounding ...


9

You should use the crop and trim options for \includegraphics command. Example: \includegraphics[trim = 10mm 80mm 20mm 5mm, clip, width=3cm]{image} The options for trim is: trim=left bottom right top, where it cropped by the appropriate amount from the sides. So, including only the right half would look like: \newlength{\imagewidth} \settowidth{\...


9

Package adjustbox Your preamble already contains package adjustbox. It provides the features you need for trimming and clipping I am not sure, which spacing is needed around the image. The following example lets the image behave as it would have the height of the upper case letter H and the depth of g. \documentclass[12pt,a4paper]{article} \usepackage{...


9

Something like this could be easily done in Lua. The code below not only prints only the first five items from the list but also shuffles the items so that the order of the questions is randomized. \starttext \startluacode -- https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle local function shuffle(list) for i = #list,2,-1 do local j =...


8

Export_fig makes all the work automatically, including margins and pdf creation. The original Matlab save result is: export_fig results (picture size is the same) is: Note: this command is improvement of savefig command.


8

Marking are usually shown in a way so that they do no show when the page is cut. One way to see what is happening is to set the print paer size to A3. For example, \setuppapersize[A5,landscape][A3] \setuparranging[2TOP] \setuplayout [ topspace=1cm, backspace=1cm, header=0mm, footer=0mm, width=middle, height=middle, marking=on, ...


8

The viewport key of graphicx can also be used to simulate trimming or cropping. viewport has 4 space-separated length arguments: left bottom right top. The remaining code should be self-explanatory. \documentclass{article} \def\FirstScale{0.5}% scale for loading \def\SecondScale{1}% scale for final \def\FileName{example-image-a}% file name \usepackage{...


8

You can use the standalone document class for this. Note that the standalone bundle offers a lot more than just cropping (as detailed in the documentation). In particular, rather than including a cropped pdf in your file, you can \input the standalone file into the mainfile using (in your example) \documentclass{article} \usepackage{pgfplots} % need to ...


8

With tikz: Also with a more condensed font: Code: \documentclass{article} \usepackage{amsmath} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc} \newcommand{\VAdjust}{0,-0.15ex}% \begin{document} \begin{tikzpicture} \node (A) {$\scalebox{1.5}{128} \sqrt{\text{e}\scalebox{1.5}{980}}$}; \draw [fill=gray!10, fill opacity=0.9, draw =none] (...


8

Sometimes the grid in the corner is to far away, when cropping to axis labels. So I made an update, where I add rectangles over the whole image. And I add an optional parameter to control how deep the rectangles are drawn. The thick lines have a distance of 10mm, the thin ones of 2mm. This is independent of the image if no width or height argument is passed ...


8

The extra whitespace you see is because a paragraph with the width \linewidth is created here. You can use the {varwidth}{<max width>} environment from the varwidth package to reduce the paragraph width to its minimum. This uses a minipage environment internally. \documentclass{article} \usepackage{varwidth} \usepackage[active,tightpage]{preview} \...


8

The shortcut convenience commands such as \vtwotone create frames starting from the page border. If you want them to bleed you have to define the frames using \newstaticframe and take the bleed into account. I don't like using internal commands in an answer, but I can't find anywhere in the crop documentation how to access the bleed dimension so I've had to ...


8

The \clipbox command from the trimclip package does this. \documentclass{article} \usepackage{trimclip} \newcommand{\crop}[1]{\clipbox*{0pt -.5ex {\width} .7ex}{#1}} \begin{document} \crop{ABCDefgh$\Omega$} \end{document} The starred version of \clipbox leaves visible everything within the specified coordinates. To crop more, decrease the .7ex. To get ...


Only top voted, non community-wiki answers of a minimum length are eligible