我有一个从 excel 转换而来的表格。我想将表格中的数字转换为数学模式,即 15 -> $15$。有什么可视化方法可以使用吗?我正在使用 TexStudio。
代码:
\begin{table}[htbp]
\centering
\caption{Comparison of microaggregation algorithms to protect different datasets for $k=\{3,4,\ldots,10\}$}
\begin{tabular}{cr|rrrrrrrrc}
\multirow{2}[1]{*}{Dataset} & \multicolumn{1}{c|}{\multirow{2}[1]{*}{Method}} & \multicolumn{8}{c}{Information Loss (\%)} & \multirow{2}[1]{*}{Elapsed time (sec)} \\
& \multicolumn{1}{c|}{} & $k=3$ & $k=4$ & $k=5$ & $k=6$ & $k=7$ & $k=8$ & $k=9$ & $k=10$ & \\
\hline
\multirow{3}[1]{*}{\dataset{Tarragona}} & KD-CBFS & 16.9500 & 19.7700 & 22.8900 & 26.4100 & 28.2600 & 29.3100 & 31.6200 & 33.2600 & $<1$ \\
& V-MDAV & 16.9507 & 19.7695 & 22.8867 & 26.4131 & 28.2616 & 29.3119 & 31.6184 & 33.2601 & $<1$ \\
& FDM & 15.8548 & 17.8439 & 22.6442 & 25.1970 & 27.7465 & 28.9472 & 30.0313 & 32.8549 & $<1$ \\ \hline
\multirow{3}[0]{*}{\dataset{Census}} & KD-CBFS & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & $<1$ \\
& V-MDAV & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & $<1$ \\
& FDM & 5.3828 & 7.0645 & 8.7178 & 10.1436 & 11.3940 & 12.6727 & 13.7732 & 14.7735 & $<1$ \\ \hline
\multirow{3}[0]{*}{\dataset{EIA}} & KD-CBFS & 0.4883 & 0.6727 & 1.7764 & 1.3157 & 2.2141 & 2.9910 & 3.4086 & 3.5474 & $<1$ \\
& V-MDAV & 0.4884 & 0.6718 & 1.7693 & 1.3157 & 2.2081 & 2.9917 & 3.4086 & 3.5474 & $1$ \\
& FDM & 0.4808 & 0.7311 & 1.0678 & 1.3533 & 1.7343 & 1.9019 & 2.0491 & 2.1674 & $<1$ \\ \hline
\multirow{3}[0]{*}{\dataset{Income}} & KD-CBFS & 0.675015 & 0.928399 & 1.19127 & 1.4107 & 1.58581 & 1.80879 & 1.94347 & 2.12738 & $1$ \\
& V-MDAV & 0.655816 & 0.928362 & 1.19121 & 1.41074 & 1.58681 & 1.80878 & 1.94346 & 2.12738 & $90$ \\
& FDM & 0.593726 & 0.838746 & 1.0747 & 1.30892 & 1.5398 & 1.75383 & 1.95588 & 2.15949 & $1$ \\ \hline
\multirow{3}[0]{*}{\dataset{Forest}} & KD-CBFS & 0.494946 & 0.703865 & 0.885494 & 1.05023 & 1.20079 & 1.33881 & 1.46986 & 1.59104 & $67$ \\
& V-MDAV & & & & & & & & & $>3600$ \\
& FDM & 0.426531 & 0.608566 & 0.782772 & 0.952619 & 1.11867 & 1.28177 & 1.44231 & 1.59784 & $65$ \\ \hline
\end{tabular}%
\label{tab:results1}%
\end{table}%
答案1
我会用siunitx
该表的包,从而避免了这个问题。
你会注意到,我曾经S[table-format=2.5]
说过,最多2
有前小数和5
数字后它。
我不确定该dataset
命令应该做什么 - 您需要适当地更改它。
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage{multirow}
\usepackage[landscape]{geometry}
\usepackage{siunitx}
\newcommand{\dataset}[1]{#1}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Comparison of microaggregation algorithms to protect different datasets for $k=\{3,4,\ldots,10\}$}
\begin{tabular}{cr|S[table-format=2.6]S[table-format=2.6]S[table-format=2.6]S[table-format=2.6]S[table-format=2.5]S[table-format=2.5]S[table-format=2.5]S[table-format=2.5]S[table-comparator=true]}
\multirow{2}[1]{*}{Dataset} & \multicolumn{1}{c|}{\multirow{2}[1]{*}{Method}} & \multicolumn{8}{c}{Information Loss (\%)} & \multirow{2}[1]{*}{Elapsed time (sec)} \\
& \multicolumn{1}{c|}{} & {$k=3$} & {$k=4$} & {$k=5$} & {$k=6$} & {$k=7$} & {$k=8$} & {$k=9$} & {$k=10$} & \\
\hline
\multirow{3}[1]{*}{\dataset{Tarragona}} & KD-CBFS & 16.9500 & 19.7700 & 22.8900 & 26.4100 & 28.2600 & 29.3100 & 31.6200 & 33.2600 & <1 \\
& V-MDAV & 16.9507 & 19.7695 & 22.8867 & 26.4131 & 28.2616 & 29.3119 & 31.6184 & 33.2601 & <1 \\
& FDM & 15.8548 & 17.8439 & 22.6442 & 25.1970 & 27.7465 & 28.9472 & 30.0313 & 32.8549 & <1 \\ \hline
\multirow{3}[0]{*}{\dataset{Census}} & KD-CBFS & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & <1 \\
& V-MDAV & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & <1 \\
& FDM & 5.3828 & 7.0645 & 8.7178 & 10.1436 & 11.3940 & 12.6727 & 13.7732 & 14.7735 & <1 \\ \hline
\multirow{3}[0]{*}{\dataset{EIA}} & KD-CBFS & 0.4883 & 0.6727 & 1.7764 & 1.3157 & 2.2141 & 2.9910 & 3.4086 & 3.5474 & <1 \\
& V-MDAV & 0.4884 & 0.6718 & 1.7693 & 1.3157 & 2.2081 & 2.9917 & 3.4086 & 3.5474 & 1 \\
& FDM & 0.4808 & 0.7311 & 1.0678 & 1.3533 & 1.7343 & 1.9019 & 2.0491 & 2.1674 & <1 \\ \hline
\multirow{3}[0]{*}{\dataset{Income}} & KD-CBFS & 0.675015 & 0.928399 & 1.19127 & 1.4107 & 1.58581 & 1.80879 & 1.94347 & 2.12738 & 1 \\
& V-MDAV & 0.655816 & 0.928362 & 1.19121 & 1.41074 & 1.58681 & 1.80878 & 1.94346 & 2.12738 & 90 \\
& FDM & 0.593726 & 0.838746 & 1.0747 & 1.30892 & 1.5398 & 1.75383 & 1.95588 & 2.15949 & 1 \\ \hline
\multirow{3}[0]{*}{\dataset{Forest}} & KD-CBFS & 0.494946 & 0.703865 & 0.885494 & 1.05023 & 1.20079 & 1.33881 & 1.46986 & 1.59104 & 67 \\
& V-MDAV & & & & & & & & & >3600 \\
& FDM & 0.426531 & 0.608566 & 0.782772 & 0.952619 & 1.11867 & 1.28177 & 1.44231 & 1.59784 & 65 \\ \hline
\end{tabular}%
\label{tab:results1}%
\end{table}%
\end{document}
为了便于比较,这里有一个使用该booktabs
包的选项
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage{multirow}
\usepackage[landscape]{geometry}
\usepackage{siunitx}
\usepackage{booktabs}
\newcommand{\dataset}[1]{#1}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Comparison of microaggregation algorithms to protect different datasets for $k=\{3,4,\ldots,10\}$}
\begin{tabular}{crS[table-format=2.6]S[table-format=2.6]S[table-format=2.6]S[table-format=2.6]S[table-format=2.5]S[table-format=2.5]S[table-format=2.5]S[table-format=2.5]S[table-comparator=true]}
\toprule
\multirow{2}[1]{*}{Dataset} & \multirow{2}[1]{*}{Method} & \multicolumn{8}{c}{Information Loss (\%)} & \multirow{2}[1]{*}{Elapsed time (sec)} \\
& & {$k=3$} & {$k=4$} & {$k=5$} & {$k=6$} & {$k=7$} & {$k=8$} & {$k=9$} & {$k=10$} & \\
\midrule
\multirow{3}[1]{*}{\dataset{Tarragona}} & KD-CBFS & 16.9500 & 19.7700 & 22.8900 & 26.4100 & 28.2600 & 29.3100 & 31.6200 & 33.2600 & <1 \\
& V-MDAV & 16.9507 & 19.7695 & 22.8867 & 26.4131 & 28.2616 & 29.3119 & 31.6184 & 33.2601 & <1 \\
& FDM & 15.8548 & 17.8439 & 22.6442 & 25.1970 & 27.7465 & 28.9472 & 30.0313 & 32.8549 & <1 \\
\cmidrule{3-11}
\multirow{3}[0]{*}{\dataset{Census}} & KD-CBFS & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & <1 \\
& V-MDAV & 5.6620 & 7.5140 & 9.0070 & 10.3654 & 11.6688 & 12.3068 & 13.3368 & 14.0730 & <1 \\
& FDM & 5.3828 & 7.0645 & 8.7178 & 10.1436 & 11.3940 & 12.6727 & 13.7732 & 14.7735 & <1 \\
\cmidrule{3-11}
\multirow{3}[0]{*}{\dataset{EIA}} & KD-CBFS & 0.4883 & 0.6727 & 1.7764 & 1.3157 & 2.2141 & 2.9910 & 3.4086 & 3.5474 & <1 \\
& V-MDAV & 0.4884 & 0.6718 & 1.7693 & 1.3157 & 2.2081 & 2.9917 & 3.4086 & 3.5474 & 1 \\
& FDM & 0.4808 & 0.7311 & 1.0678 & 1.3533 & 1.7343 & 1.9019 & 2.0491 & 2.1674 & <1 \\
\cmidrule{3-11}
\multirow{3}[0]{*}{\dataset{Income}} & KD-CBFS & 0.675015 & 0.928399 & 1.19127 & 1.4107 & 1.58581 & 1.80879 & 1.94347 & 2.12738 & 1 \\
& V-MDAV & 0.655816 & 0.928362 & 1.19121 & 1.41074 & 1.58681 & 1.80878 & 1.94346 & 2.12738 & 90 \\
& FDM & 0.593726 & 0.838746 & 1.0747 & 1.30892 & 1.5398 & 1.75383 & 1.95588 & 2.15949 & 1 \\
\cmidrule{3-11}
\multirow{3}[0]{*}{\dataset{Forest}} & KD-CBFS & 0.494946 & 0.703865 & 0.885494 & 1.05023 & 1.20079 & 1.33881 & 1.46986 & 1.59104 & 67 \\
& V-MDAV & & & & & & & & & >3600 \\
& FDM & 0.426531 & 0.608566 & 0.782772 & 0.952619 & 1.11867 & 1.28177 & 1.44231 & 1.59784 & 65 \\
\bottomrule
\end{tabular}%
\label{tab:results1}%
\end{table}%
\end{document}