這個問題表面上看起來可能類似並排小頁數字但事實上我相信它是不同的。
這段程式碼產生的結果是混亂的(文字應該在相應圖像的左對齊下方,所有內容都應該很好地排列,並且圖像應該左右齊平),正如這段程式碼後面的螢幕截圖所示。如果我們刪除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}