3

When I am trying to insert a .jpg image in one column of a table in latex. it is getting shrunk and not able to stretch or fit into the whole column. it is getting shrunk or squeezed & when I am trying to increase the length of the logo, parallel the width is also increasing creating a large unnecessary space in second column. Please tell me the solution for this.

The following is the code which I have used to print the table with one of the logo inserted in first column, but which is getting squeezed:

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage{color}
\usepackage{hyperref}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{array}
\usepackage{fancyhdr}
\usepackage[letterpaper ,vmargin ={5mm,15mm},hmargin ={20mm,20mm},includehead, includefoot]{geometry}
\begin{document}
%\fancyhf{}
%\begin{table}[ht]
%\centering
\begin {tabular}{|l|c|l|}
\hline
\includegraphics[width =0.20\columnwidth]{./ieslogo.jpg} & xxxxxxx & xxxxxx\\
\hspace{0.125in} xxxxxxxx & xxxxxT  & xxx \\
\hspace{0.125in} xxxxxx & xxxxxxxx & Page 1\\
\hspace{0.125in} xxxxxx  &\\
\hline
\end{tabular}
%\end{table}
\end{document}

If I increase the length of the logo, the width also is increasing causing unnecessary space in second column. Kindly provide me the solution for this.

6
  • 2
    If the image is being scaled then you have some markup specifying that, if it isn't being scaled by the right amount then that markup is wrong. You need to provide a complete small document that demonstrates the effect, then someone will be able to suggest working markup. – David Carlisle Jun 5 '14 at 12:07
  • 2
    Adding your code and screenshot of output can make the debugging easier. – nidhin Jun 5 '14 at 12:16
  • I think, you should rather scale=0.3 or something to reduce all dimensions of the logo image proportionally. And inserting that way will put the logo on top of the table row and the next column text will be at the bottom. – user31729 Jun 9 '14 at 6:18
  • I have tried all the ways to fit the image in first column,i used scale command also. The table should fit into entire page because it is a header for my document. When i tried using scale also. the width is increasing according to height. the logo should fit exactly in first column without getting shrinked and whole table should be fit in the page like a header. Kindly tell me how to do it. – koliparthi Jun 9 '14 at 8:55
  • 3
    @koliparthi Why do you keep editing the posts and answers, breaking the images? It makes your question very difficult to understand. – mforbes Jun 10 '14 at 8:25
1

To be awfully honest, I'm not sure if I understand what your problem exactly is. But I give it a shot. You can either scale your image by a value (as Christian Hupfer mentioned in his comment) or, you can explicitly enforce both width and height. The difference is that the aspect ratio is preserved in the former:

% Enforcing the width and height explicitly
\includegraphics[width=0.4\columnwidth, height=0.1\textheight]{./image.png}

% v.s Scaling down/up the image
\includegraphics[scale=0.08]{./image.png}

Please note that you need to modify the values of width, height and scale according to the size of your logo.

Edit

In response to OP's problem regarding the vertical alignment, one solution is to use \raisebox:

\raisebox{-\totalheight}{\includegraphics[width=0.4\columnwidth, height=0.1\textheight]{./image.png}}

You can also define how much you wanna raise by multiplying it by a gain (e.g. \raisebox{-0.8\totalheight}).

8
  • In second column, there is a gap formed above the sentence "BPCU CONTROL AND INDICATION" which is unnecessary.. This line should start from first row of second column. but it is not happening – koliparthi Jun 9 '14 at 9:01
  • @koliparthi: The (vertical you mean?) gap is an issue of the definition of your tabular environment. A multirow cell would improve that – user31729 Jun 9 '14 at 9:07
  • 1
    @koliparthi, look at the edited post. Also consider Christian's comment. – Pouya Jun 9 '14 at 9:16
  • 1
    @Pouya: Nice logo ;-) – user31729 Jun 9 '14 at 9:39
  • 1
    @ChristianHupfer, thank you brother :D. Yours as well ;) – Pouya Jun 9 '14 at 10:15
0

I used another image but changed the name to yours in this code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage[letterpaper ,vmargin ={5mm,15mm},hmargin ={20mm,20mm},includehead, includefoot]{geometry}
\begin{document}
\noindent
\begin{tabularx}{\linewidth}{|X|>{\centering}X|l|}\hline
\hspace*{-\tabcolsep}%
\raisebox{\dimexpr-\height+\ht\strutbox}{%
  \includegraphics[trim=0 800 0 0,clip,width=\dimexpr\linewidth+2\tabcolsep]{herby_trecker}} \newline
\hspace{0.125in}\tabular{l}  
  \strut\\
  Xxxxxxxx Xxxxxxxxxx\\
  Xxxxxxxx,Xxxxxxxx 61108-7929\\
  XXXXX 99167
  \endtabular   
  & 
   \tabular[t]{c}
    \strut\\
    XXXX XXXXXXX XXX XXXXXXXXXX\\
    XXXXXX XXXXXXXXXXXX XXXX\\
    XXXXXXXXX XXX XXXXXXXXXX\\
    XXXXXXX
   \endtabular
  & 
   \tabular[t]{l}
    \strut\\
    XX1967-7\\
    Xxx.X \\
    Page 1
   \endtabular\\\hline
\end{tabularx}

\end{document}

enter image description here

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.