TeX - LaTeX Asked by AgilePro on March 11, 2021
I would like a very simple table, a paragraph in the left column, and an image in the right with a label under the image. For some strange reason, LaTeX is putting a bunch of white space before the paragraph, and I can’t figure out why:
noindentbegin{tabular}{|p{4in} p{1in}|}
hline
Note: The strange word which occurs three times on the form above (including alone on the far right column) has been explained to me by a French speaker as the Latin word "idem" meaning "the same" or as we would say colloquially in English, ``ditto.''& includegraphics[width=1in]{img/ch06-Ditto.png} ``ditto''
hline
end{tabular}
The result appears like this:
Anyone know why it appears to have added a extra blank line into the top of the left column?
This stems from the image being set on the baseline of the first line, which makes it stick out (vertically) above the line.
To avoid this, "raise" the image into place:
documentclass{article}
usepackage{graphicx}
begin{document}
noindentbegin{tabular}{ | p{4in} p{1in} | }
hline
Note: The strange word which occurs three times on the form above (including alone on
the far right column) has been explained to me by a French speaker as the Latin
word ``idem'' meaning ``the same'' or as we would say colloquially in English, ``ditto.''
& {centeringbegin{tabular}[t]{ @{} c @{} }
raisebox{dimexpr-height+.6normalbaselineskip}{includegraphics[width=0.5in]{example-image}}
``ditto''
end{tabular}par}
hline
end{tabular}
end{document}
Note that I've set the right-hand column inside its own tabular
. This allows you some freedom for breaking the lines how you want them, rather than forcing a line-break as a label for your image.
Correct answer by Werner on March 11, 2021
No need to guess:
documentclass{article}
usepackage{graphicx}
begin{document}
noindent
begin{tabular}{|p{4in} p{1in}|}
hline
Note: The strange word which occurs three times on the form above
(including alone on the far right column) has been explained to me
by a French speaker as the Latin word ``idem'' meaning ``the same''
or as we would say colloquially in English, ``ditto.''
& centering
vspace{-htstrutbox}includegraphics[width=1in,height=0.4in]{example-image} ``ditto''
tabularnewline
hline
end{tabular}
end{document}
The vspace
will set the baseline of the (top aligned) parbox in the second column, but we need to back up by the height of the strut that LaTeX adds automatically.
In the code I added height
to emulate your picture; of course you'll have to remove it.
Answered by egreg on March 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP