[texhax] Placing unknown images arbitrarily by lower left corner

Peter Davis pfd at pfdstudio.com
Sun Apr 3 01:57:49 CEST 2011


On Wed, Mar 30, 2011 at 1:35 PM, Peter Davis <pfd at pfdstudio.com> wrote:

> I'm working on a program to convert XML documents into LaTeX.  The XML has
> several possibly ways of specifying how an image should be placed, and I'm
> trying to find ways to produce LaTeX that will place the image correctly,
> without having to actually open the image file in the XML->LaTeX converter.



I had some success just using \begin{picture}(w,h) to reserve the area for
the picture.  Then \put(x,y) let me place the image within that area.  So I
tried using Heiko's settobox package to get the dimension of the image, but
the picture environment won't let me specify actual dimensions.  They
apparently have to be dimensionless quantities:

\begin{picture}(400,300) %works
\begin{picture}(400pt,300pt) %fails  (! Missing number, treated as zero.)

I was hoping to do something like the following example, but I don't know
how to get around the "missing number" problem.  Am I barking up the wrong
tree?  Thanks!

\documentclass[letterpaper]{article}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage[absolute]{textpos}
\usepackage{settobox}
\setlength{\TPHorizModule}{1bp}
\setlength{\TPVertModule}{\TPHorizModule}
\setlength{\parindent}{0pt}
\setlength{\unitlength}{1bp}
\pagestyle{empty}
\newlength{\imgHeight}
\newlength{\imgWidth}
\usepackage[paperwidth=792.000000bp,paperheight=612.000000bp]{geometry}

\newsavebox{\PicA}\sbox{\PicA}{\includegraphics[scale=1.0]{C:/Users/Public/Pictures/Sample
Pictures/Chrysanthemum.jpg}}

\begin{document}

\begin{textblock}{235.000000}(12.000000,20.000000)

\settoboxtotalheight{\imgHeight}{\PicA}
\settoboxwidth{\imgWidth}{\PicA}

\begin{picture}(\imgWidth,\imgHeight)
\usebox{\PicA}
\end{picture}

\end{textblock}

\end{document}


-- 
----
The Tech Curmudgeon
http://www.techcurmudgeon.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20110402/751834a7/attachment.html>


More information about the texhax mailing list