![如何将图像转换为表格?](https://linux22.com/image/350691/%E5%A6%82%E4%BD%95%E5%B0%86%E5%9B%BE%E5%83%8F%E8%BD%AC%E6%8D%A2%E4%B8%BA%E8%A1%A8%E6%A0%BC%EF%BC%9F.png)
我正在使用 LaTeX 撰写研究论文,到目前为止,我必须在论文中包含 5 个主要比较表。我已手动将下图转换为表格,但这很令人沮丧。有什么方法可以将图像记录转换为 LaTeX 中的表格记录吗?
我正在使用以下代码来生成表格:
\renewcommand{\arraystretch}{0.95}
\setlength{\tabcolsep}{1pt}
\begin{table}
\centering
\vspace{-0.5cm}
\caption{List of top 20 Mutual Information Words for male (left) and female(right) class with the highest mutual information}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|}
\hline
WORD & MI & PFC & PMC & F\_CT & M\_CT & WORD & MI & PFC & PMC & F\_CT & M\_CT \\ \hline
users & 0.003 & 0.086 & 0.914 & 5 & 53 & love & 0.004 & 0.635 & 0.365 & 399 & 229 \\ \hline
data & 0.002 & 0.180 & 0.820 & 16 & 73 & mom & 0.004 & 0.785 & 0.215 & 117 & 32 \\ \hline
similar & 0.002 & 0.219 & 0.781 & 25 & 89 & husband* & 0.004 & 0.796 & 0.204 & 109 & 28 \\ \hline
its & 0.002 & 0.371 & 0.629 & 251 & 425 & my & 0.003 & 0.557 & 0.443 & 1082 & 859 \\ \hline
game* & 0.002 & 0.309 & 0.691 & 80 & 179 & lunch* & 0.003 & 0.756 & 0.244 & 102 & 33 \\ \hline
team* & 0.002 & 0.284 & 0.716 & 55 & 139 & food* & 0.003 & 0.665 & 0.336 & 204 & 103 \\ \hline
system* & 0.002 & 0.293 & 0.707 & 58 & 140 & lovely & 0.003 & 0.774 & 0.226 & 89 & 26 \\ \hline
topps & 0.002 & 0.000 & 1.000 & 0 & 21 & me & 0.003 & 0.557 & 0.443 & 873 & 694 \\ \hline
video* & 0.002 & 0.311 & 0.689 & 70 & 155 & meal* & 0.002 & 0.789 & 0.211 & 71 & 19 \\ \hline
govern* & 0.002 & 0.256 & 0.744 & 32 & 93 & eating & 0.002 & 0.726 & 0.274 & 98 & 37 \\ \hline
global* & 0.002 & 0.158 & 0.824 & 9 & 48 & her & 0.002 & 0.586 & 0.414 & 432 & 305 \\ \hline
technologies & 0.002 & 0.042 & 0.958 & 1 & 23 & beaut* & 0.002 & 0.639 & 0.361 & 207 & 117 \\ \hline
john & 0.002 & 0.254 & 0.746 & 30 & 88 & baby* & 0.002 & 0.717 & 0.283 & 99 & 39 \\ \hline
model & 0.002 & 0.227 & 0.773 & 20 & 68 & gorgeous* & 0.002 & 0.831 & 0.169 & 49 & 10 \\ \hline
web & 0.002 & 0.273 & 0.727 & 36 & 96 & ladies & 0.002 & 0.846 & 0.154 & 44 & 8 \\ \hline
bill & 0.002 & 0.255 & 0.745 & 28 & 82 & cute* & 0.002 & 0.750 & 0.250 & 75 & 25 \\ \hline
developer & 0.002 & 0.045 & 0.955 & 1 & 21 & fabulous* & 0.002 & 0.881 & 0.119 & 37 & 5 \\ \hline
notion & 0.001 & 0.077 & 0.923 & 2 & 24 & potato & 0.002 & 1.000 & 0.000 & 20 & 0 \\ \hline
opera* & 0.001 & 0.268 & 0.732 & 30 & 82 & kids* & 0.002 & 0.650 & 0.350 & 154 & 83 \\ \hline
mike & 0.001 & 0.176 & 0.824 & 9 & 42 & she & 0.002 & 0.579 & 0.421 & 398 & 289 \\
\hline
\end{tabular}
\label{fig:top20list}
\end{table}
答案1
LaTeX 中没有解决这个问题的方法。
您必须搜索一些 OCR 软件才能从图像中获取数据。然后您将获得原始数据。可以使用其他工具将其传输到 LaTeX 表(搜索 excel-to-latex 或类似工具)。
最简单的解决方案是插入图像并将*.png
其设置在table
环境中。
但是如果你正确设置这些表,你会发现它作为真正的 LaTeX 代码要好得多。
% arara: pdflatex
\documentclass{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{rotating}
\usepackage{siunitx}
\begin{document}
\begin{sidewaystable}
\centering
\caption{List of top 20 Mutual Information Words for male (left) and female (right) class with the highest mutual information}
\begin{tabular}{%
l
S[table-format=1.3]
S[table-format=1.3]
S[table-format=1.3]
S[table-format=2.0]
S[table-format=3.0]
@{\hskip 1cm}
l
S[table-format=1.3]
S[table-format=1.3]
S[table-format=1.3]
S[table-format=4.0]
S[table-format=3.0]
}
\toprule
WORD & MI & PFC & PMC & F\_CT & M\_CT & WORD & MI & PFC & PMC & F\_CT & M\_CT \\ \midrule
users & 0.003 & 0.086 & 0.914 & 5 & 53 & love & 0.004 & 0.635 & 0.365 & 399 & 229 \\
data & 0.002 & 0.180 & 0.820 & 16 & 73 & mom & 0.004 & 0.785 & 0.215 & 117 & 32 \\
similar & 0.002 & 0.219 & 0.781 & 25 & 89 & husband* & 0.004 & 0.796 & 0.204 & 109 & 28 \\
its & 0.002 & 0.371 & 0.629 & 251 & 425 & my & 0.003 & 0.557 & 0.443 & 1082 & 859 \\
game* & 0.002 & 0.309 & 0.691 & 80 & 179 & lunch* & 0.003 & 0.756 & 0.244 & 102 & 33 \\
team* & 0.002 & 0.284 & 0.716 & 55 & 139 & food* & 0.003 & 0.665 & 0.336 & 204 & 103 \\
system* & 0.002 & 0.293 & 0.707 & 58 & 140 & lovely & 0.003 & 0.774 & 0.226 & 89 & 26 \\
topps & 0.002 & 0.000 & 1.000 & 0 & 21 & me & 0.003 & 0.557 & 0.443 & 873 & 694 \\
video* & 0.002 & 0.311 & 0.689 & 70 & 155 & meal* & 0.002 & 0.789 & 0.211 & 71 & 19 \\
govern* & 0.002 & 0.256 & 0.744 & 32 & 93 & eating & 0.002 & 0.726 & 0.274 & 98 & 37 \\
global* & 0.002 & 0.158 & 0.824 & 9 & 48 & her & 0.002 & 0.586 & 0.414 & 432 & 305 \\
technologies & 0.002 & 0.042 & 0.958 & 1 & 23 & beaut* & 0.002 & 0.639 & 0.361 & 207 & 117 \\
john & 0.002 & 0.254 & 0.746 & 30 & 88 & baby* & 0.002 & 0.717 & 0.283 & 99 & 39 \\
model & 0.002 & 0.227 & 0.773 & 20 & 68 & gorgeous* & 0.002 & 0.831 & 0.169 & 49 & 10 \\
web & 0.002 & 0.273 & 0.727 & 36 & 96 & ladies & 0.002 & 0.846 & 0.154 & 44 & 8 \\
bill & 0.002 & 0.255 & 0.745 & 28 & 82 & cute* & 0.002 & 0.750 & 0.250 & 75 & 25 \\
developer & 0.002 & 0.045 & 0.955 & 1 & 21 & fabulous* & 0.002 & 0.881 & 0.119 & 37 & 5 \\
notion & 0.001 & 0.077 & 0.923 & 2 & 24 & potato & 0.002 & 1.000 & 0.000 & 20 & 0 \\
opera* & 0.001 & 0.268 & 0.732 & 30 & 82 & kids* & 0.002 & 0.650 & 0.350 & 154 & 83 \\
mike & 0.001 & 0.176 & 0.824 & 9 & 42 & she & 0.002 & 0.579 & 0.421 & 398 & 289 \\
\bottomrule
\end{tabular}
\label{fig:top20list}
\end{sidewaystable}
\end{document}