Search Results

Search found 2 results on 1 pages for 'drfrogsplat'.

Page 1/1 | 1 

  • Can pdflatex (or any tex package) automatically rescale included images which have been reduced in s

    - by drfrogsplat
    I'm writing my thesis in LaTeX, generating it with pdflatex. I have a large number of figures, many of which are bitmaps (as opposed to SVG) in PNG/JPEG format. I've generally created them to be fairly high resolution (say 1600x1200-ish) to ensure that whatever size they end up in the document, they'll be at least 300dpi when printed. As I'm writing/laying out the document, I'm including graphics (using \includegraphics from the graphicx package) and setting widths/heights as appropriate (e.g. subfigures are quite small). I don't need the images to be any more than about 300 dpi at best, so where I have shrunk a 1600x1200 image down to say 5cm, the image is now at 800 dpi. So despite including some very small (on the page) images, the PDF is becoming quite large. Is there a way to tell pdflatex or graphicx (or something else involved?) to convert all images to a maximum of 300 dpi, based on the dimensions I'm setting with say \includegraphics[width=2in]{filename}? i.e. so it scales the image to a max of 600x600 pixels as it includes it in the PDF (leaving the original file untouched). I know I can resize the original images with various command line applications, and include the pre-resized versions, but given the images vary in size considerably, it wouldn't be as simple as making sure they're all 300dpi for a constant printed size. It'd also be nice to be able to easily create different versions of PDFs (web vs final print) without resizing images manually, so that the 'web' PDF capped images at say 72-100 dpi while the final print one could cap at 600 (if at all).

    Read the article

  • Can I make a LaTeX macro 'return' a filename?

    - by drfrogsplat
    I'm writing my thesis/dissertation and since its an on-going work I don't always have the actual images ready for the figures I put into my document, but for various reasons want to automatically have it substitute a dummy figure in place when the included graphics file doesn't exist. E.g. I can do something like \includegraphics[width=8cm]{\chapdir/figures/fluxcapacitor} (where \chapdir is a macro for my 'current' chapter directory, e.g. \def\chapdir{./ch_timetravel} and if there's no ./ch_timetravel/figures/fluxcapacitor.jpg it'll insert ./commands/dummy.jpg instead. I've structured my macros (perhaps naïvely?) so that I have a macro (\figFileOrDummy) that determines the appropriate file to include by checking if the argument provided to it exists, so that I can call \includegraphics[properties]{\figFileOrDummy{\chapdir/figures/fluxcapacitor}}. Except I'm getting various errors depending on how I try to call this, which seem to suggest that I'm approaching the problem in a fundamentally flawed way as far as 'good LaTeX programming' goes. Here's the macro to check if the file exists (and 'return' either filename or the dummy filename): \newcommand{\figFileOrDummy}[1]{% % Figure base name (no extension) to be used if the file exists \def\fodname{#1}% \def\dummyfig{commands/dummy}% % Check if output is PS (.EPS) or PDF (.JPG/.PDF/.PNG/...) figures \ifx\pdfoutput\undefined% % EPS figures only \IfFileExists{\fodname.eps}{}{\def\fodname{\dummyfig}}% \else% % Check existence of various extensions: PDF, TIF, TIFF, JPG, JPEG, PNG, MPS \def\figtest{0}% flag below compared to this value \IfFileExists{\fodname.pdf}{\def\figfilenamefound{1}}{\def\figfilenamefound{0}}% \IfFileExists{\fodname.jpg}{\def\figfilenamefound{1}}{}% \IfFileExists{\fodname.png}{\def\figfilenamefound{1}}{}% % and so on... % If no files found matching the filename (flag is 0) then use the dummy figure \ifx\figfilenamefound\figtest% \def\fodname{\dummyfig}% \fi% \fi% % 'return' the filename \fodname% }% Alternatively, here's a much simpler version which seems to have similar problems: \newcommand{\figFileOrDummy}[1]{% \def\dummyfig{commands/dummy}% \dummyfig% } The \def commands seems to be processed after the expansion of the macro they're trying to define, so it ends up being \def {commands/dummy}... (note the space after \def) and obviously complains. Also it seems to treat the literal contents of the macro as the filename for \includegraphics, rather than resolving/expanding it first, so complains that the file '\def {commands/dummy}... .png' doesn't exist.. I've tried also doing something like \edef\figfilename{\figFileOrDummy{\chapdir/figures/fluxcapacitor}} to try to force it to make \figfilename hold just the value rather than the full macro, but I get an Undefined control sequence error complaining the variables I'm trying to \def in the \figFileOrDummy macro are undefined. So my question is either How do I make this macro expand properly?; or If this is the wrong way of structuring my macros, how should I actually structure such a macro, in order to be able to insert dummy/real figures automatically?; or Is there a package that already handles this type of thing nicely that I've overlooked? I feel like I'm missing something pretty fundamental here...

    Read the article

1