![表格内使用编号列表代替项目符号](https://linux22.com/image/435147/%E8%A1%A8%E6%A0%BC%E5%86%85%E4%BD%BF%E7%94%A8%E7%BC%96%E5%8F%B7%E5%88%97%E8%A1%A8%E4%BB%A3%E6%9B%BF%E9%A1%B9%E7%9B%AE%E7%AC%A6%E5%8F%B7.png)
我正在使用以下代码借用自这里并进行相应修改,写下算法的步骤:
\documentclass{article}
\usepackage{booktabs}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}
\begin{document}
\begin{table}
\centering
\begin{tabular}{l}
\toprule
\multicolumn{1}{l}{\textbf{Algorithm} }
\\
\midrule
\tabitem This is step 1 \\
\tabitem This is step 2 \\
\tabitem This is step 3 \\
\tabitem This is step 4 \\
\hline
\end{tabular}
\end{table}
\end{document}
我想要编号列表而不是项目符号。该怎么做?我无法使用环境,enumerate
因为代码未编译。
答案1
快速又肮脏......
\documentclass{article}
\usepackage{booktabs}
\newcommand{\tabitem}[1]{~~\llap{#1.}~~}% <-- Modified
\begin{document}
\begin{table}
\centering
\begin{tabular}{l}
\toprule
\multicolumn{1}{l}{\textbf{Algorithm} }
\\
\midrule
\tabitem{1} This is step 1 \\
\tabitem{2} This is step 2 \\
\tabitem{3} This is step 3 \\
\tabitem{4} This is step 4 \\
\hline
\end{tabular}
\end{table}
\end{document}