我有一张表格和一张图形,我需要让它们并排显示。图形显示的位置比表格高。我需要对齐它们,使它们的大小相等。这是脚本和输出与我需要的进行比较。
\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{graphicx}
\begin{document}
\begin{minipage}{\textwidth}
\begin{minipage}[b]{0.49\textwidth}
\centering
\captionof{table}{Table}
\begin{tabular}{ll}
\hline\noalign{\smallskip}
Item1 & Item2 \\
\noalign{\smallskip}
\hline
\noalign{\smallskip}
C & 100 \\
B & 200 \\
C & 300 \\
\hline
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{venndiagram2}
\captionof{figure}{Diagram.}
\end{minipage}
\end{minipage}
\end{document}
答案1
- 外层
minipage
是多余的 - 两个内
mipages
页都有适当的位置选项[b]
- 您需要在表格中添加位置选项
[b]
- 您
booktabs
可以获得表格中水平线的更简单的代码
梅威瑟:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage[demo]{graphicx}
\usepackage{booktabs}
\begin{document}
\begin{minipage}[b]{0.49\textwidth}
\centering
\captionof{table}{Table}
\begin{tabular}[b]{ll}
\toprule %[0.3pt]
Item1 & Item2 \\
\midrule %[0.3pt]
\noalign{\smallskip}
C & 100 \\
B & 200 \\
C & 300 \\
\bottomrule %[0.3pt]
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{venndiagram2}
\captionof{figure}{Diagram.}
\end{minipage}
\end{document}