Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code:

\documentclass[a4paper,landscape,12pt,oneside]{scrbook}
\usepackage[english]{babel} % Quotes won't work without babel
\usepackage[utf8]{inputenc}  % This is very important!
\usepackage[T1]{fontenc}

\usepackage{graphicx}
\usepackage[pdfborder={0 0 0}, breaklinks=true, pdftex=true, raiselinks=true]{hyperref}
\usepackage{tabularx}

\newcolumntype{Y}{>{\raggedright}X}

\begin{document}
\begin{figure}[h!]
\subsubsection{Lorem ipsum dolor}
\begin{tabularx}{\linewidth}{YY}\hline

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{enumerate}
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\end{enumerate}
&\textbf{\centering \vspace{-10pt} \resizebox{.8\linewidth}{!}{\vspace{-10pt}          \includegraphics[width=1\linewidth]{Lorem.png}} \caption{Lorem ipsum dolor}
}\tabularnewline \hline
\end{tabularx}

\end{figure}
\clearpage
\end{document}

When I set \resizebox{\linewidth}, the left column of the table aligns the text perfectly, but if I set \resizebox{.8\linewidth} the left side of the table, aligns the text at the point where the right side ends. Can somebody tell me what I am doing wrong in here, or maybe give me some tip, please?

What I see:

enter image description here

What I want:

enter image description here

share|improve this question
    
Why putting the \includegraphics inside a \resizebox? Just do \includegraphics[width=.8\linewidth]{...}. –  egreg Dec 3 '12 at 13:36
    
@egreg: You are right, but still the left side of the table is misaligned, when setting the \includegraphics{width=.8\linewidth} –  dima Dec 3 '12 at 13:39
    
What precisely do you want to attain? –  egreg Dec 3 '12 at 13:42
    
@egreg: I want to have a 2 column table, with a text on the left side and a figure on the right side, to be both at the top of the page. Now only the right side with the figure is at the top, and the text is somewhere in the middle of left column. –  dima Dec 3 '12 at 13:45
    
You haven't shown what result you get or used an image that we can use so it is hard to tell what you are seeing. \resizebox{.8\linewidth}{!}{\vspace{-10pt} the vspace will be ignored (as it would be inside \mbox) and the white space will mean that the box is a word space wider than the image. –  David Carlisle Dec 3 '12 at 13:45

1 Answer 1

up vote 2 down vote accepted

enter image description here

Using the [demo] option to graphicx so it doesn't need the actual image file.

The image below fixes the spacing issues in the posted example. Note however that if teh actual code is as here just a single row two column tabularx It would be vastly more efficient, and easier to automatically get the vertical centering, if the table was not used and the graphic simply placed after a \begin{minipage}[c] containing the enumeration.

\documentclass[a4paper,landscape,12pt,oneside]{scrbook}
\usepackage[english]{babel} % Quotes won't work without babel
\usepackage[utf8]{inputenc}  % This is very important!
\usepackage[T1]{fontenc}

\usepackage[demo]{graphicx}
\usepackage[pdfborder={0 0 0}, breaklinks=true, pdftex=true, raiselinks=true]{hyperref}
\usepackage{tabularx}

\newcolumntype{Y}{>{\raggedright}X}

\begin{document}
\begin{figure}[htp!]
\subsubsection{Lorem ipsum dolor}
\begin{tabularx}{\linewidth}{YY}\hline

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{enumerate}
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\item  \textbf{Lorem ipsum dolor}\\Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\end{enumerate}
&\centering 
\vspace*{10\baselineskip} 
\includegraphics[width=.8\linewidth]{Lorem.png}
 \caption{Lorem ipsum dolor}\tabularnewline \hline
\end{tabularx}

\end{figure}
\clearpage
\end{document}
share|improve this answer
    
Thanks a lot it works perfectly. –  dima Dec 3 '12 at 14:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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