TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

Overwriting Images
TUG logo

Main page

Index
UK FAQ
Documentation
Software
CTAN
Search CTAN:

Statistics

Google c.t.t.

Google d.c.t.t.

 


 


Using picture Environment |  Using pstricks package  | 


Example 1

The solution from pstricks doesn't work for PDF-outputs with pdflatex. In this case you need the picture-Environment. But than you have the problem that you need from the image height only it's value not the unit. With a little trick we can split a length into it's value and unit:
\newlength{\dummyLaenge}
\newcounter{LaengenWert}
\newsavebox{\ImageBox}
Before you insert the float or image without a float write in TeX (red):
  \savebox{\ImageBox}{\includegraphics[width=8cm]{rose}}
  \setlength{\unitlength}{1cm}
  \setlength{\dummyLaenge}{\ht\ImageBox}
  \divide\dummyLaenge by\unitlength
  \setcounter{LaengenWert}{\dummyLaenge}
Noe insert the float as usual and write in Tex (red)
    \centering
    \resizebox{0.8\textwidth}{!}{%
      \begin{picture}(8,\theLaengenWert)
        \linethickness{1pt}
        \put(1,1.05){\makebox(0,0)[t]%
             {\colorbox{white}%
             {\unit{1}{\micro\meter}}}}
        \put(0.5,1.15){\line(1,0){1}}
        \put(0.5,1){\line(0,1){0.3}}
        \put(1.5,1){\line(0,1){0.3}}
       \usebox{\ImageBox}
      \end{picture}%
    }
With entering a caption you'll get with Export->pdflatex the following image

To get this example run, you need also some more packages:
\usepackage{graphicx}
\usepackage[amssymb,Gray,textstyle,thinqspace]{SIunits}

Example 2

The following hack uses some of LaTeX's special commands (thanks to Heiko Overdiek):

Example 3

Another possibility is to redefine the picture environment., so that it accepts length's with a unit like the one from pstricks package. Write in preamble:
\renewenvironment{picture}[4]{%
  \@picht#2
  \setbox\@picbox\hb@xt@#1
    \bgroup
    \hskip -#3\unitlength
    \lower #4\unitlength\hbox\bgroup
      \ignorespaces%
}{%
  \egroup\hss\egroup
    \ht\@picbox\@picht\dp\@picbox\z@
    \mbox{\box\@picbox}%
}
Start the picture environment with
\begin{picture}{\wd\ImageBox}{\ht\ImageBox}{0}{0}

local time: Sat Aug 24 02:19:57 CEST 2019 ; file is: 57.2714351851852 days old
contact webmaster _at_ TeXnik.de