如何格式化不同尺寸的影像?

如何格式化不同尺寸的影像?

我正在為課堂寫一份報告,但我不知道如何以更好的方式格式化多個圖像(特別是 4 個圖像)。我可以尋求協助嗎?這是我的程式碼:

        \begin{figure}[H]
        \begin{minipage}[t]{0.5\textwidth}
        \includegraphics[width=\linewidth]{tables/B/5.png}
        \end{minipage}
        \hspace{\fill}
        \begin{minipage}[t]{0.5\textwidth}
        \includegraphics[width=\linewidth, height=\textwidth]{tables/B/6.png}
        \end{minipage}
        \vspace*{1cm}
        \begin{minipage}[t]{0.5\textwidth}
        \includegraphics[width=\linewidth]{tables/B/7.png}
        \end{minipage}
        \hspace{\fill}
        \begin{minipage}[t]{0.5\textwidth}
        \includegraphics[width=\linewidth, height=\textwidth{tables/B/8.png}
        \end{minipage}
        \end{figure}

但這會輸出以下令人討厭的頁面:

在此輸入影像描述

答案1

正如我在評論中建議的那樣,我不建議包含表格圖片。我知道用tabular環境建立大型表可能有點乏味,但是如果您正在對資料檔案進行製表,那麼有pgfplotstable這會非常有幫助(它是與PGF圖)。

這是一個如何使用它的小例子:

\documentclass[border=5,export]{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\begin{filecontents*}{data.dat}
   1.   0.                  0.
   2.   1.3862943611198906  0.34657359027997264
   3.   3.295836866004329   0.1831020481113516
   4.   5.545177444479562   0.057762265046662105
   5.   8.047189562170502   0.013411982603617503
   6.  10.75055681536833    0.0024885548183722988
   7.  13.621371043387192   0.0003860932835427209
   8.  16.635532333438686   0.000051573450934519735
   9.  19.775021196025975   6.054961908444168e-6
  10.  23.02585092994046    6.345307244802815e-7
\end{filecontents*}

\begin{document}
\begin{table}
  \pgfplotstabletypeset[
    columns/0/.style={
      column name=\(n\),
    },
    columns/1/.style={
      column name=\(x_{n}\),
      fixed, zerofill,
      precision=3,
    },
    columns/2/.style={
      column name=\(\Delta x_{n}\),
      sci, zerofill,
      precision=4,
    },
    every head row/.style={
      before row=\toprule,
      after row=\midrule,
    },
    every last row/.style={
      after row=\bottomrule,
    },
  ]{data.dat}
\end{table}
\end{document}

其產生:

使用 PGFplotstable

如果您仍然希望將表格作為圖片包含在內,那麼我發現這個問題這與你的非常相似。假設您僅使用graphicx且其他套件沒有修改其他環境,那麼您可以透過以下方法修復它:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
  \begin{minipage}[t][][b]{0.5\textwidth}
    \includegraphics[width=\linewidth]{1.png}
  \end{minipage}
  \begin{minipage}[t][][b]{0.5\textwidth}
    \includegraphics[width=\linewidth]{2.png}
  \end{minipage}
  \begin{minipage}[t][][b]{0.5\textwidth}
    \includegraphics[width=\linewidth]{3.png}
  \end{minipage}
  \begin{minipage}[t][][b]{0.5\textwidth}
    \includegraphics[width=\linewidth]{4.png}
  \end{minipage}
\end{figure}
\end{document}

輸出為:

固定對齊方式

相關內容