0

I have a .tex file which goes something like this:

\NeedsTeXFormat{LaTeX2e}
\documentclass[border=10pt]{standalone}
\usepackage{fontspec}
\newcommand*{\NewFont}[1]{%
  \expandafter\newfontfamily\csname#1\endcsname{#1}%
}
\newcommand*{\SetFont}[1]{%
  \csname#1\endcsname
  \ignorespaces
}
\newdimen\FontSize
\newdimen\FontUnitLength
\setlength{\FontUnitLength}{.75bp}
\newcommand*{\SetSize}[1]{%
  \setlength{\FontSize}{#1\FontUnitLength}%
  \fontsize{\FontSize}{1.2\FontSize}\selectfont
  \ignorespaces
}
\usepackage{graphicx}
\newcommand*{\Put}{}
\def\Put(#1,#2)(#3,#4)#5{%
  %\put(#1,#2){\makebox(#3,#4)[lb]{\resizebox{#3\unitlength}{!}{#5}}}%
  \put(#1,#2){%
    \makebox(#3,#4)[lb]{%
      \resizebox{#3\unitlength}{#4\unitlength}{%
        \raisebox{\depth}{#5}%
      }%
    }%
  }%
  %\put(#1,#2){\makebox(#3,#4)[lb]{#5}}%
}
\setlength{\unitlength}{1bp}
\NewFont{Trebuchet_MS_Bold}
\NewFont{Verdana_Bold}
\NewFont{Georgia}
\NewFont{Arial}
\NewFont{Trebuchet_MS}
\NewFont{Verdana}
\NewFont{Verdana_Bold_Italic}
\NewFont{Trebuchet_MS_Italic}
\NewFont{Arial_Bold}
\NewFont{Times_New_Roman_Bold_Italic}
\NewFont{Georgia_Italic}
\NewFont{Times_New_Roman_Italic}
\NewFont{Verdana_Italic}
\NewFont{Times_New_Roman}
\NewFont{Courier_New}
\begin{document}
\begin{picture}(939,1287)
\SetFont{Courier_New}
\SetSize{48}
\Put(12,1249)(131,36){Swine}
\Put(159,1249)(55,38){flu}
\Put(230,1240)(181,47){tightens}
\Put(428,1249)(49,36){its}
\Put(492,1240)(84,45){grip}
\Put(592,1249)(99,27){over}
\Put(708,1249)(105,38){India}
\SetSize{19}
\Put(589,1192)(53,14){Swine}
\Put(649,1192)(23,14){flu}
\Put(681,1192)(29,14){has}
\Put(716,1188)(88,18){tightened}
\Put(813,1192)(19,14){its}
\Put(839,1188)(34,14){grip}
\Put(880,1192)(41,10){over}
\SetSize{17}
\Put(133,1156)(1,21){j}
\Put(590,1158)(312,18){India,withthedeathtollreaching}
\SetSize{20}
\Put(589,1131)(45,14){close}
\Put(641,1131)(18,13){to}
\Put(668,1131)(48,14){1000.}
\Put(725,1131)(47,14){Fresh}

and more......

I use the above latex file to finally create a PDF having words at particular placed XY Coordinates (known beforehand) where the put command is used. Now, apart from this, I also want to include the pictures (stored as seperate image files by the names 1.jpg, 2.jpg...) at particular X-Y Coordinates as I did with words.

What I did was, in the .tex file, I inserted this line (before the positioning of the word Swine): \Put(415,1171){\includegraphics[width=515, height=243{/home/John/Desktop/1.jpg}}

Here, (415,1171) are the coordinates and the path is the location of the image. When I try to convert the above tex file into a PDF, it shows an error (which without was working completely fine) and gives the following error and stops:

</home/John/Desktop/1.jpg, id=1, 516.93124pt x 243.91125pt>
! Illegal unit of measure (pt inserted).
<to be read again> 
  • 1
    There is a typo (missing ] after height=243. I am not sure if you can pass dimensionless arguments to width and height. Try with \includegraphics[width=515pt, height=243pt]{/home/John/Desktop/1.jpg} – Aditya Apr 9 '16 at 4:28
  • @John Package textpos can be used to position text and graphics at specific positions on a page. – Ross Apr 9 '16 at 4:34
  • @Aditya, it gives the following error: Runaway argument? 4){\makebox (15,7)[lb]{\resizebox {15\unitlength }{7\unitlength }{\raisebox \ETC . ! File ended while scanning use of \Put. <inserted text> \par <*> abc . I think this error is coming because I am not adding the line at a proper place (that is, after word Swine). Do you think I should put it somewhere else? – John Apr 9 '16 at 5:36
  • @Nunkulla, how can I add it in this file? Can you give me an example by editing the above tex file? – John Apr 9 '16 at 5:37
  • Your \Put macro needs two couples of distances before text. Try \Put(415,1171)(100,100){\includegraphics[width=515pt, height=243pt]{example-image}}. – Paul Gaborit Apr 9 '16 at 6:30
1

The Textpos package can be useful for this purpose. The positioning of your elements would require a lot of interpretation so the following code is illustrative only. The textboxes in the example are shown relative to the margins, which are generated using the showframe option of the geometry package.

\documentclass[border=10pt,a4paper]{article}
\usepackage[lmargin=24mm,rmargin=24mm,tmargin=25mm,bmargin=25mm,showframe]{geometry} %Set margins and show them
\usepackage[absolute,showboxes]{textpos} % Positioning textblocks in absolute terms
\usepackage{graphicx}
\usepackage{mwe}

\setlength{\TPHorizModule}{1mm}
\setlength{\TPVertModule}{1mm}

\setlength{\parindent}{0pt}

\begin{document}

\begin{textblock}{2}(24,25) % Place a * at the intersection at the top and left margins
    $*$ %Top left
\end{textblock}

\begin{textblock}{40}(140,50) %Place an image in a box 40 mm wide 140 mm from the left edge and 50 mm from the top
    \centering
    \includegraphics[scale=0.20]{example-image}%From mwe package
\end{textblock}

\begin{textblock}{20}(24,100) %Place a textblock on the left margin (24 mm), 100 mm from the top.
Swine \\
flu \\
tightens \\
its \\
grip \\
over \\
India
\end{textblock}

\begin{textblock}{40}(90,120) %Place a textblock 90 mm from the left edge and 120 mm from the top
\raggedleft
Swine \\
flu \\
tightens \\
its \\
grip \\
over \\
India
\end{textblock}

\begin{textblock}{2}(186,272) % Place a * at the intersection of the bottom and right margins
     $*$ %Bottom right
\end{textblock}

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.