我有以下代码:
\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}
当我设置时\resizebox{\linewidth}
,表格的左列会完美对齐文本,但如果我设置\resizebox{.8\linewidth}
表格的左侧,则会将文本对齐到右侧结束的位置。有人能告诉我我在这里做错了什么吗,或者给我一些提示,好吗?
我所看到的:
我想要的是:
答案1
使用该[demo]
选项,graphicx
因此它不需要实际的图像文件。
下图修复了已发布示例中的间距问题。但请注意,如果实际代码与此处一样,只有一行两列,那么如果不使用表格,而是将图形简单地放置在包含枚举的tabularx
后面,那么效率会大大提高,并且更容易自动获得垂直居中。\begin{minipage}[c]
\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}