您能帮我修改一下这个表格吗?这个表格的问题是无法以正确的方式移至下一页,请说明图形的大小以及图形的位置。
\begin{longtable}[c]{@{}|c|c|c|c|c|c|c|c|c|@{}}
\caption{Bacteria isolates on different media}
\label{tab:my-table}\\
\toprule
\textbf{Sr.No} &
\textbf{Reference Code} &
\textbf{Sample Location} &
\textbf{Colony Color} &
\textbf{Colony Morphology} &
\textbf{Pigmentation} &
\textbf{Media} &
\textbf{Predicted Name Of Strain} &
\textbf{Figures} \\* \midrule
\endhead
%
1 &
EMB(P)1 &
Islamabad &
Green sheen &
Circular &
Green Sheen &
\begin{tabular}[c]{@{}c@{}}Eosin methylene\\ \\ blue agar\end{tabular} &
\textit{\textbf{E.coil}} &
\\* \midrule
2 &
MSA(P)1 &
Islamabad &
Yellow &
Punctiform &
Yellow &
Mannitol salt agar &
\textit{\textbf{\begin{tabular}[c]{@{}c@{}}Staphylococcus\\ \\ Epidermidis\end{tabular}}} &
\\* \midrule
3 & MACC(P)1 & Islamabad & Off white & Circular & Off white & MacConkey agar & \textit{\textbf{Salmonella}} & \\* \midrule
4 & MSA(P)2 & Islamabad & White & Circular & White & Mannitol salt agar & \textit{\textbf{Staphylococcus aureus}} & \\* \midrule
5 &
B.A(P)1 &
Islamabad &
White &
Smooth &
White &
\begin{tabular}[c]{@{}c@{}}Blood \\ \\ Agar\end{tabular} &
\textit{\textbf{Pseudomonas aeruginosa}} &
\\* \midrule
6 & B.A(P)2 & Islamabad & White & Circular & White & Blood agar & \textit{\textbf{Lactobacilli}} & \\* \midrule
7 & MACC(P)2 & Islamabad & Pink & Circular & Pink & MacConkey agar & \textit{\textbf{Klebsiella}} & \\* \midrule
8 & MACC(P)3 & Islamabad & Purple & Irregular & Purple & MacConkey agar & \textit{\textbf{pseudomonas}} & \\* \midrule
9 & MSA(P)3 & Islamabad & Crystal White & spherical & Crystal White & Mannitol salt agar & \textit{\textbf{Salmonella}} & \\* \midrule
10 & B.A(P)3 & Islamabad & White & Puntiform & White & Blood agar & \textit{\textbf{Staphylococcus}} & \\* \midrule
11 & MACC(P)4 & Islamabad & Orange to amber & Circular & Orange to amber & MacConkey agar & \textit{\textbf{Shigella}} & \\* \midrule
12 & MSA(P)4 & Islamabad & Yellow & Circular & Yellow & Mannitol salt agar & \textit{\textbf{S. aureus}} & \\* \midrule
13 & MACC(P)5 & Islamabad & Pink to purple & Circular & Pink to purple & MacConkey & \textit{\textbf{Klebisella}} & \\* \bottomrule
\end{longtable}
答案1
假设页面尺寸为标准,边距不超过 2.5 厘米,只要允许单元格换行,表格就应该可以放在页面上。下面,通过使用列来实现换行。tabularx
我还建议删除所有竖线(它们没有必要;事实上,它们会分散注意力),并将大多数 替换为\midrule
。\addlinespace
我还会删除所有大胆的以避免造成有些粗俗和吵闹的“外观”。
我承认我不明白您打算用“数字”栏做什么。
\documentclass{article} % choose a suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters suitably
\usepackage{booktabs,tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\hspace{0pt}}X}
\newlength\mylen
\settowidth\mylen{MACC(P)5} % width of column 2
\hyphenation{sal-mo-nel-la pseudo-monas mac-con-key aeru-gi-nosa epi-der-mi-dis}
\begin{document}
\begin{table}
\setlength\tabcolsep{2.5pt} % default: 6pt
\caption{Bacteria isolates on different media\strut}
\label{tab:my-table}
\begin{tabularx}{\textwidth}{@{} l p{\mylen} *{6}{L} l @{}}
\toprule
Sr.No &
Reference Code & Sample Location & Colony Color & Colony Morphology &
Pigmentation & Media & Predicted Name of Strain & Figures \\
\midrule
1 & EMB(P)1 & Islamabad & Green sheen & Circular & Green Sheen & Eosin methylene blue agar & \textit{E. coli} & \\ \addlinespace
2 & MSA(P)1 & Islamabad & Yellow & Punctiform& Yellow & Mannitol salt agar & \textit{Staphylococcus Epidermidis}&\\ \addlinespace
3 & MACC(P)1 & Islamabad & Off white & Circular & Off white & MacConkey agar & \textit{Salmonella} & \\ \addlinespace
4 & MSA(P)2 & Islamabad & White & Circular & White & Mannitol salt agar & \textit{Staphylococcus aureus} & \\ \addlinespace
5 & B.A(P)1 & Islamabad & White & Smooth & White & Blood Agar & \textit{Pseudomonas aeruginosa} & \\ \addlinespace
6 & B.A(P)2 & Islamabad & White & Circular & White & Blood agar & \textit{Lactobacilli} & \\ \addlinespace
7 & MACC(P)2 & Islamabad & Pink & Circular & Pink & MacConkey agar & \textit{Klebsiella} & \\ \addlinespace
8 & MACC(P)3 & Islamabad & Purple & Irregular & Purple & MacConkey agar & \textit{pseudomonas} & \\ \addlinespace
9 & MSA(P)3 & Islamabad & Crystal White & spherical & Crystal White & Mannitol salt agar & \textit{Salmonella} & \\ \addlinespace
10 & B.A(P)3 & Islamabad & White & Punctiform& White & Blood agar & \textit{Staphylococcus} & \\ \addlinespace
11 & MACC(P)4 & Islamabad & Orange to amber & Circular & Orange to amber & MacConkey agar & \textit{Shigella} & \\ \addlinespace
12 & MSA(P)4 & Islamabad & Yellow & Circular & Yellow & Mannitol salt agar & \textit{S. aureus} & \\ \addlinespace
13 & MACC(P)5 & Islamabad & Pink to purple & Circular & Pink to purple & MacConkey & \textit{Klebisella} & \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
我仍然不确定我是否正确理解了你的问题,但我猜以下内容至少有点接近你正在寻找的输出:
\documentclass{article}
\usepackage{graphicx}
\usepackage{xltabular}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage{makecell}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\usepackage{pdflscape}
\usepackage{calc}
\usepackage[export]{adjustbox}
\begin{document}
\begin{landscape}
\begin{xltabular}{\linewidth}{@{}cccccc>{\centering\arraybackslash}p{\widthof{MacConkey}}>{\itshape\bfseries}Xc@{}}
\caption{Bacteria isolates on different media}
\label{tab:my-table}\\
\toprule
\thead{Sr.\\No} &
\thead{Reference\\ Code} &
\thead{Sample\\ Location} &
\thead{Colony\\ Color} &
\thead{Colony\\ Morphology} &
\thead{Pigmen-\\tation} &
\thead{Media} &
\upshape\thead{Predicted\\ Name Of Strain} &
\thead{Figures} \\ \midrule
\endfirsthead
\caption[]{Bacteria isolates on different media - continued from previous page}\\
\toprule
\thead{Sr.\\No} &
\thead{Reference\\ Code} &
\thead{Sample\\ Location} &
\thead{Colony\\ Color} &
\thead{Colony\\ Morphology} &
\thead{Pigmen-\\tation} &
\thead{Media} &
\upshape\thead{Predicted Name\\ Of Strain} &
\thead{Figures} \\ \midrule
\endhead
%
1 &
EMB(P)1 &
Islamabad &
\makecell[t]{Green\\ sheen} &
Circular &
\makecell[t]{Green\\ sheen} &
\makecell[t]{Eosin\\ methylene\\blue agar} &
E.coil & \includegraphics[width=3cm, valign=t]{example-image-a}
\\ \midrule
2 &
MSA(P)1 & Islamabad & Yellow & Punctiform & Yellow & Mannitol salt agar & Staphylococcus Epidermidis &\includegraphics[width=3cm, valign=t]{example-image-a}
\\ \midrule
3 & MACC(P)1 & Islamabad & \makecell[t]{Off\\ white} & Circular & \makecell[t]{Off\\ white} & MacConkey agar & Salmonella & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
4 & MSA(P)2 & Islamabad & White & Circular & White & Mannitol salt agar & Staphylococcus aureus & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
5 &
B.A(P)1 &
Islamabad &
White &
Smooth &
White &
Blood Agar &
Pseudomonas aeruginosa & \includegraphics[width=3cm, valign=t]{example-image-a}
\\ \midrule
6 & B.A(P)2 & Islamabad & White & Circular & White & Blood agar & Lactobacilli & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
7 & MACC(P)2 & Islamabad & Pink & Circular & Pink & MacConkey agar & Klebsiella & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
8 & MACC(P)3 & Islamabad & Purple & Irregular & Purple & MacConkey agar & pseudomonas & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
9 & MSA(P)3 & Islamabad & \makecell[t]{Crystal\\ White} & spherical & \makecell[t]{Crystal\\ White} & Mannitol salt agar & Salmonella & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
10 & B.A(P)3 & Islamabad & White & Puntiform & White & Blood agar & Staphylococcus & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
11 & MACC(P)4 & Islamabad & \makecell[t]{Orange to\\ amber} & Circular & \makecell[t]{Orange to\\ amber} & MacConkey agar & Shigella & \includegraphics[width=3cm, valign=t]{example-image-a} \\ \midrule
12 & MSA(P)4 & Islamabad & Yellow & Circular & Yellow & Mannitol salt agar & S. aureus & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \midrule
13 & MACC(P)5 & Islamabad & \makecell[t]{Pink to\\ purple} & Circular & \makecell[t]{Pink to\\ purple} & MacConkey & Klebisell & \includegraphics[width=3cm, valign=t]{example-image-a}\\ \bottomrule
\end{xltabular}
\end{landscape}
\end{document}
以下是考虑到以下信息后更新的代码版本当我在表格的列中添加数字时,表格中出现了问题,这是我的结果
\documentclass{article}
\usepackage{graphicx}
\usepackage{xltabular}
\usepackage[top=1.5in,
bottom=1.19in,inner=1.5in,outer=1in,
headheight=0.3in,headsep=0.2in]{geometry}
\usepackage{booktabs}
\usepackage{makecell}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\usepackage{pdflscape}
\usepackage{calc}
\usepackage[export]{adjustbox}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\begin{landscape}
\setlength{\tabcolsep}{4pt}
\begin{xltabular}{\linewidth}{@{}cccccc>{\centering\arraybackslash}m{\widthof{MacConkey}}>{\itshape\bfseries}Xc@{}}
\caption{Bacteria isolates on different media}
\label{tab:my-table}\\
\toprule
\thead{Sr.\\No} &
\thead{Reference\\ Code} &
\thead{Sample\\ Location} &
\thead{Colony\\ Color} &
\thead{Colony\\ Morphology} &
\thead{Pigmen-\\tation} &
\thead{Media} &
\upshape\thead{Predicted\\ Name Of Strain} &
\thead{Figures} \\ \midrule
\endfirsthead
\caption[]{Bacteria isolates on different media - continued from previous page}\\
\toprule
\thead{Sr.\\No} &
\thead{Reference\\ Code} &
\thead{Sample\\ Location} &
\thead{Colony\\ Color} &
\thead{Colony\\ Morphology} &
\thead{Pigmen-\\tation} &
\thead{Media} &
\upshape\thead{Predicted Name\\ Of Strain} &
\thead{Figures} \\ \midrule
\endhead
%
1 &
EMB(P)1 &
Islamabad &
Green sheen &
Circular &
Green sheen &
Eosin methylene blue agar &
E.coil & \includegraphics[width=3cm, valign=c]{example-image-a}
\\ \midrule
2 &
MSA(P)1 & Islamabad & Yellow & Punctiform & Yellow & Mannitol salt agar & Staphylococcus Epidermidis &\includegraphics[width=3cm, valign=c]{example-image-a}
\\ \midrule
3 & MACC(P)1 & Islamabad & Off white & Circular & Off white & MacConkey agar & Salmonella & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
4 & MSA(P)2 & Islamabad & White & Circular & White & Mannitol salt agar & Staphylococcus aureus & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
5 &
B.A(P)1 &
Islamabad &
White &
Smooth &
White &
Blood Agar &
Pseudomonas aeruginosa & \includegraphics[width=3cm, valign=c]{example-image-a}
\\ \midrule
6 & B.A(P)2 & Islamabad & White & Circular & White & Blood agar & Lactobacilli & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
7 & MACC(P)2 & Islamabad & Pink & Circular & Pink & MacConkey agar & Klebsiella & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
8 & MACC(P)3 & Islamabad & Purple & Irregular & Purple & MacConkey agar & pseudomonas & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
9 & MSA(P)3 & Islamabad & Crystal White & spherical & Crystal White & Mannitol salt agar & Salmonella & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
10 & B.A(P)3 & Islamabad & White & Puntiform & White & Blood agar & Staphylococcus & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
11 & MACC(P)4 & Islamabad & Orange to amber & Circular & Orange to amber & MacConkey agar & Shigella & \includegraphics[width=3cm, valign=c]{example-image-a} \\ \midrule
12 & MSA(P)4 & Islamabad & Yellow & Circular & Yellow & Mannitol salt agar & S. aureus & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \midrule
13 & MACC(P)5 & Islamabad & Pink to purple & Circular & Pink to purple & MacConkey & Klebisell & \includegraphics[width=3cm, valign=c]{example-image-a}\\ \bottomrule
\end{xltabular}
\end{landscape}
\end{document}
答案3
问题不太清楚,所以有些建议可能没有解决你的问题。我建议使用:
- 表格的横向页面(因为使用正常字体大小时它会比较宽)
xltabular
表格(与@leandriis 的回答类似),- 对于除第一列和最后一列之外的所有列,使用
C
从X
列派生的列 \makcell{...}
从表主体中删除所有命令- 用于包含要使用的图像
\adjustimage{}{...}
,其中声明图像大小、位置和边距的通用设置
\documentclass{article}
\usepackage{geometry}
\usepackage{booktabs, makecell, xltabular}
\renewcommand{\theadfont}{\small\bfseries}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash%
\hsize=#1\hsize}X}
\usepackage{pdflscape}
\usepackage[skip=1ex]{caption}
\usepackage[export]{adjustbox} % it also load graphicx
\begin{document}
\begin{landscape}
\adjustboxset{width=24mm, valign=t, margin=0pt 2pt 0pt 2pt}
\setlength\tabcolsep{4pt}
\begin{xltabular}{\linewidth}{@{} c
*{3}{L{0.85}}
L{1.05}
*{2}{L{0.9}}
>{\itshape\bfseries}L{1.6}
c @{}}
\caption{Bacteria isolates on different media}
\label{tab:my-table}\\
\toprule
\thead{Sr.\\No}
& \thead{Reference\\ Code}
& \thead{Sample\\ Location}
& \thead{Colony\\ Color}
& \thead{Colony\\ Morphology}
& \thead{Pigmen-\\tation}
& \thead{Media}
& \upshape\thead{Predicted\\ Name Of Strain}
& \thead{Figures} \\ \midrule
\endfirsthead
\caption[]{Bacteria isolates on different media (cont).} \\
\toprule
\thead{Sr.\\No}
& \thead{Reference\\ Code}
& \thead{Sample\\ Location}
& \thead{Colony\\ Color}
& \thead{Colony\\ Morphology}
& \thead{Pigmen-\\tation}
& \thead{Media}
& \upshape\thead{Predicted\\ Name Of Strain}
& \thead{Figures} \\ \midrule
\endhead
\multicolumn{9}{r}{\footnotesize\emph{Continue on the next page}}
\endfoot
\endlastfoot
%%%% table body
1 & EMB(P)1
& Islamabad
& Green sheen
& Circular
& Green sheen
& Eosin methylene blue agar
& E.coil
& \adjustimage{}{example-image-duck} \\ \midrule
2 & MSA(P)1
& Islamabad
& Yellow
& Punctiform
& Yellow
& Mannitol salt agar
& Staphylococcus Epidermidis
& \adjustimage{}{example-image-duck} \\ \midrule
3 & MACC(P)1
& Islamabad
& Off white
& Circular
& Off white
& MacConkey agar
& Salmonella
& \adjustimage{}{example-image-duck} \\ \midrule
4 & MSA(P)2
& Islamabad & White
& Circular
& White
& Mannitol salt agar
& Staphylococcus aureus
& \adjustimage{}{example-image-duck} \\ \midrule
5 & B.A(P)1
& Islamabad
& White
& Smooth
& White
& Blood Agar
& Pseudomonas aeruginosa
& \adjustimage{}{example-image-duck} \\ \midrule
6 & B.A(P)2
& Islamabad
& White
& Circular
& White
& Blood agar
& Lactobacilli
& \adjustimage{}{example-image-duck} \\ \midrule
7 & MACC(P)2
& Islamabad
& Pink
& Circular
& Pink
& MacConkey agar
& Klebsiella
& \adjustimage{}{example-image-duck} \\ \midrule
8 & MACC(P)3
& Islamabad
& Purple
& Irregular
& Purple
& MacConkey agar
& Pseudomonas
& \adjustimage{}{example-image-duck} \\ \midrule
9 & MSA(P)3
& Islamabad
& Crystal White
& spherical
& Crystal White
& Mannitol salt agar
& Salmonella
& \adjustimage{}{example-image-duck} \\ \midrule
10 & B.A(P)3
& Islamabad
& White
& Puntiform
& White
& Blood agar
& Staphylococcus
& \adjustimage{}{example-image-duck} \\ \midrule
11 & MACC(P)4
& Islamabad
& Orange to amber
& Circular
& Orange to amber
& MacConkey agar
& Shigella
& \adjustimage{}{example-image-duck} \\ \midrule
12 & MSA(P)4
& Islamabad
& Yellow
& Circular
& Yellow
& Mannitol salt agar
& S. aureus
& \adjustimage{}{example-image-duck} \\ \midrule
13 & MACC(P)5
& Islamabad
& Pink to purple
& Circular
& Pink to purple
& MacConkey
& Klebisell
& \adjustimage{}{example-image-duck} \\ \bottomrule
\end{xltabular}
\end{landscape}
\end{document}
正如您所见,表格在页面之间被很好地、正确地划分。
附录: 如果您喜欢纵向页面格式的表格,那么您需要减少:
- 表格主体字体大小,例如
\footnotesize
- 列标题字体大小,例如
\scriptsize
\tabcolsep
大小,例如 3pt- 减小图像尺寸,例如减小至宽度=18mm
经过此缩减后,表格可以放在一页上(假设您提供了表格的完整内容),因此可以将其插入浮动figure
环境中:
\documentclass{article}
\usepackage[top=1.5in, % consider your next (unclear) question
bottom=1.19in,inner=1.5in,outer=1in,
headheight=0.3in,headsep=0.2in]{geometry}
\usepackage{booktabs, makecell, xltabular}
\renewcommand{\theadfont}{\scriptsize\bfseries}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash%
\hsize=#1\hsize}X}
\usepackage{pdflscape}
\usepackage[skip=1ex]{caption}
\usepackage[export]{adjustbox} % it also load graphicx
\begin{document}
\begin{table}[p]
\caption{Bacteria isolates on different media}
\label{tab:my-table}
\footnotesize
\adjustboxset{width=18mm, valign=t, margin=0pt 2pt 0pt 2pt}
\setlength\tabcolsep{3pt}
%
\begin{tabularx}{\linewidth}{@{}c
L{1}
*{2}{L{0.9}}
L{1.1}
L{0.8}
L{0.9}
>{\itshape\bfseries}L{1.4}
c @{}}
\toprule
\thead{Sr.\\No}
& \thead{Reference\\ Code}
& \thead{Sample\\ Location}
& \thead{Colony\\ Color}
& \thead{Colony\\ Morphology}
& \thead{Pigmen-\\tation}
& \thead{Media}
& \upshape\thead{Predicted\\ Name Of Strain}
& \thead{Figures} \\ \midrule
%%%% table body
1 & EMB(P)1
& Islamabad
& Green sheen
& Circular
& Green sheen
& Eosin methylene blue agar
& E.coil
& \adjustimage{}{example-image-duck} \\ \midrule
2 & MSA(P)1
& Islamabad
& Yellow
& Punctiform
& Yellow
& Mannitol salt agar
& Staphylococcus Epidermidis
& \adjustimage{}{example-image-duck} \\ \midrule
3 & MACC(P)1
& Islamabad
& Off white
& Circular
& Off white
& MacConkey agar
& Salmonella
& \adjustimage{}{example-image-duck} \\ \midrule
4 & MSA(P)2
& Islamabad & White
& Circular
& White
& Mannitol salt agar
& Staphylococcus aureus
& \adjustimage{}{example-image-duck} \\ \midrule
5 & B.A(P)1
& Islamabad
& White
& Smooth
& White
& Blood Agar
& Pseudomonas aeruginosa
& \adjustimage{}{example-image-duck} \\ \midrule
6 & B.A(P)2
& Islamabad
& White
& Circular
& White
& Blood agar
& Lactobacilli
& \adjustimage{}{example-image-duck} \\ \midrule
7 & MACC(P)2
& Islamabad
& Pink
& Circular
& Pink
& MacConkey agar
& Klebsiella
& \adjustimage{}{example-image-duck} \\ \midrule
8 & MACC(P)3
& Islamabad
& Purple
& Irregular
& Purple
& MacConkey agar
& Pseudomonas
& \adjustimage{}{example-image-duck} \\ \midrule
9 & MSA(P)3
& Islamabad
& Crystal White
& spherical
& Crystal White
& Mannitol salt agar
& Salmonella
& \adjustimage{}{example-image-duck} \\ \midrule
10 & B.A(P)3
& Islamabad
& White
& Puntiform
& White
& Blood agar
& Staphylococcus
& \adjustimage{}{example-image-duck} \\ \midrule
11 & MACC(P)4
& Islamabad
& Orange to amber
& Circular
& Orange to amber
& MacConkey agar
& Shigella
& \adjustimage{}{example-image-duck} \\ \midrule
12 & MSA(P)4
& Islamabad
& Yellow
& Circular
& Yellow
& Mannitol salt agar
& S. aureus
& \adjustimage{}{example-image-duck} \\ \midrule
13 & MACC(P)5
& Islamabad
& Pink to purple
& Circular
& Pink to purple
& MacConkey
& Klebisell
& \adjustimage{}{example-image-duck} \\ \bottomrule
\end{tabularx}
\end{table}
\end{document}
此解决方案的缺点是图片大小。要获得更大的图片,您需要寻找其他解决方案(例如,使表格可以溢出外部文本边框)或坚持使用第一个解决方案,即使用横向表格。