这个问题表面上看起来类似于并排的小页面数字但事实上我相信它是不同的。
这段代码产生的结果很混乱(文本应该在相应的图像下左对齐,所有内容应该排列整齐,图像应该左右齐平),如代码后面的屏幕截图所示。如果我们删除keepaspectratio=true
注释掉的行中所示的内容,布局看起来会好很多,但图像会扭曲。我想将其用作不同图像的模板,因此重要的是不要使用图像的细节。
请注意,用 分隔的代码的最后三个部分\vspace{1ex}
是相同的,因此实际上唯一代码的数量比从长度上看起来的要少得多。
首先,我该如何修复这个问题?其次,我该如何改变它,这样它不仅可以修复,而且每次我做一些小的改变时,整个布局和外观都会发生巨大的变化,就像已经发生过两次一样?这太令人沮丧了。谢谢。
\documentclass{article}
\usepackage{colortbl}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\setlength{\fboxsep}{0pt}
\begin{document}
\begin{center}
\colorbox{blue}{\parbox[t][0.5cm][c]{\textwidth}{\bfseries{HEADER}}}
\end{center}
\lipsum[2]
\noindent\begin{minipage}[b]{.5\textwidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some text.
\end{minipage}
\hfill
\begin{minipage}[b]{.5\linewidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some more text.
\end{minipage}
\vspace{1ex}
\noindent\begin{minipage}[b]{.5\textwidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some text.
\end{minipage}
\hfill
\begin{minipage}[b]{.5\linewidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some more text.
\end{minipage}
\vspace{1ex}
\noindent\begin{minipage}[b]{.5\textwidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some text.
\end{minipage}
\hfill
\begin{minipage}[b]{.5\linewidth}
%\includegraphics[width=\linewidth, height=.25\textheight]{elephant}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some more text.
\end{minipage}
\end{document}
有关图片创意共享信息这里
答案1
更改行后\includegraphics
并避免多余的空白;您可以测量图像的宽度并使用该宽度来minipage
获得文本的正确对齐方式:
\documentclass{article}
\usepackage{colortbl}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\newlength\imageheight
\newlength\imagewidth
\settowidth\imagewidth{\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}}
\setlength{\fboxsep}{0pt}
\begin{document}
\begin{center}
\colorbox{blue}{\parbox[t][0.5cm][c]{\textwidth}{\bfseries{HEADER}}}
\end{center}
\lipsum[2]
\noindent\begin{minipage}[b]{\imagewidth}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}\\
Some text.
\end{minipage}%
\hfill
\begin{minipage}[b]{\imagewidth}
\hfill
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}\\
\hfill Some more text.
\end{minipage}
\vspace{1ex}
\noindent\begin{minipage}[b]{\imagewidth}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}\\
Some text.
\end{minipage}%
\hfill
\begin{minipage}[b]{\imagewidth}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}\\
Some more text.
\end{minipage}
\vspace{1ex}
\noindent\begin{minipage}[b]{\imagewidth}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}\\
Some text.
\end{minipage}%
\hfill%
\begin{minipage}[b]{\imagewidth}
\includegraphics[width=\linewidth, height=.25\textheight, keepaspectratio=true]{elephant}
Some more text.
\end{minipage}
\end{document}