我正在尝试将一个表格从 MS Word 转换为 LaTeX,该表格在第一列包含一个大图像,右侧包含几行文本。作为初学者,我不知道如何实现这一点。我使用的是 2 列文档。它可以包含在一列中吗?
请帮忙。
编辑:虽然我做不到,但我为我的文档提供了 MWE,以便让大家了解我正在使用的软件包。
\documentclass[twocolumn]{svjour3}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage[linesnumbered,lined,boxed,commentsnumbered]{algorithm2e}
\usepackage{amsmath}
\usepackage{graphicx}
%Table packages
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\usepackage{makecell}
\renewcommand{\theadfont}{\bfseries}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\usepackage{siunitx}
\usepackage{multirow}
\begin{document}
% just a random table from this article
% System Components
\begin{table}
% table caption is above the table
\caption{Hardware components and specifications}
\label{tab:2} % Give a unique label
% For LaTeX tables use
\begin{tabularx}
{\linewidth}{>{\raggedright\arraybackslash}p{1in}
>{\raggedright\arraybackslash}p{1in}
X
}
\toprule
\thead{Component} &\thead{ Hardware\\specification} & \thead{Architecture\\application}\\
\midrule\\
\textbf{Android Mobile} & Redmi 4A with Android 8.0, 2GB RAM, 16GB ROM & Client device for data acquisition \\
\addlinespace
\textbf{Processing and monitoring Unit} & Raspberry Pi 4 with 4GB RAM on latest Raspbian OS (December 2020) & Main processing unit that runs all the algorithms.\\
\addlinespace
\textbf{Wi-Fi Router(Optional)} & Mi Band-3 high speed router with 70 Mbps Broadband connection & The communication hub for the architecture in indoor monitoring.\\
\noalign{\smallskip}\hline
\end{tabularx}
\end{table}
\end {document}
答案1
使用tabularx
表格是正确的方法......
经过一些小的调整后,可以获得以下结果:
\documentclass[twocolumn]{svjour3}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage{graphicx}
%Table packages
\usepackage{booktabs, makecell, multirow, tabularx}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{siunitx}% new
\usepackage{lipsum} % new, for dummy text filler
\begin{document}
\lipsum[1]
\begin{table}[ht]
\caption{Hardware components and specifications}
\label{tab:2}
\small
\sisetup{product-units = single}
\setcellgapes{2pt}
\makegapedcells
\setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{@{}>{\hsize=1.1\hsize}X
@{\quad}l
>{\hsize=0.9\hsize}L @{}}
\cmidrule[\heavyrulewidth]{2-3}
\multirow{22}{=}{\includegraphics[height=22\baselineskip,
width=\linewidth]{example-image-duck}}
& Model
& \thead[l]{Xiaomi Redmi 4a} \\
\cmidrule{2-3}
& OS & Android~8.0 \\
& Size & \SI{14 x 0.9 x 7}{\centi\meter} \\
& CPU & \SI{1.4}{\giga\hertz} Qualcomm Snapdragon~425 64-bit Cortex~A53 quad core processor \\
& RAM/ROM & \SI{3}{\giga B}/\SI{32}{\giga B} \\
& Resolution & \SI{1280 x 720}{pixels} resolution and \SI{296}{pixel} density \\
& Connectivity & Wi-Fi~802.11~b/g/n, Bluetooth~4.0 \\
& Sensor & on board BMI160 accelerometer \\
& Weight & \SI{132}{\gram} \\
& Battery & \SI{3120}{\milli\ampere} \\
& GPS & A-GPS, Glonass \\
\cmidrule{2-3}
\end{tabularx}
\end{table}
\lipsum[2-6]
\end{document}
正如您从 MWE 中看到的,与您的 MWE 相比,进行了以下更改/调整:
- 对于单位使用
siunitx
包 - 表格使用
\small
字体大小 - 删除了垂直线和大部分水平线(该表具有更多“专业
looks
- 通过使用包
makegapedcells
中定义的,向每行插入 2pt 的垂直填充makecell
- 最后两列的测试左对齐
答案2
您可以使用该multirow
包及其\multirow
提供的命令。在下文中,我还使用了\makecell
该makecell
包中的命令,轻松地在单元格中添加换行符tabular
。
\documentclass{article}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{graphicx}
\begin{document}
\begin{center}
\begin{tabular}{c|c|c|}
\cline{2-3}
\multirow{11}{*}{\includegraphics[scale=0.67]{example-image-9x16}}
& Model & \textbf{Xiaomi Redmi~4a} \\
\cline{2-3}
& OS & Android~8.0 \\
\cline{2-3}
& Size & $14 \times 0.9 \times 7$ cm \\
\cline{2-3}
& CPU & \makecell{1.4~GHz Qualcomm\\Snapdragon~425 64-bit\\Cortex~A53 quad core\\processor} \\
\cline{2-3}
& RAM\slash ROM & 3~GB\slash 32 GB \\
\cline{2-3}
& Resolution & \makecell{$1280 \times 720$ pixels\\resolution and 296\\pixel density} \\
\cline{2-3}
& Connectivity & \makecell{Wi-Fi~802.11~b/g/n,\\Bluetooth~4.0} \\
\cline{2-3}
& Sensor & \makecell{ON BOARD BMI160\\ACCELEROMETER} \\
\cline{2-3}
& Weight & 132~Grams \\
\cline{2-3}
& Battery & 3120~mA \\
\cline{2-3}
& GPS & A-GPS, Glonass \\
\cline{2-3}
\end{tabular}
\end{center}
\end{document}
顺便说一句,我不确定表格是否真的看起来那么好看,因为有那么多水平/垂直线 --- 当然,YMMV。通常我推荐该booktabs
包及其\toprule
、\midrule
和命令,但这些往往会生成看起来像是直接来自科学文章的表格(当然\cmidrule
,\bottomrule
如果您实际编写的就是这些,那就太好了)。