我想使用包含表的新环境的命令来检索表。
基本上是这样的:
\begin{measurtab}{Test 2110}
\value{0.0}{0.0}
\end{measuretab}
应该会出现这样的情况:
我尝试将以下内容作为最小示例,但我对参数数量以及如何正确使用计数器感到困惑。我不是 TeXpert,所以我希望您能帮助我解决我做错的事情。
\documentclass{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{amsmath, amsfonts, amssymb, enumerate, verbatim, scrpage2, xcolor, array, graphicx, tabularx, wrapfig, booktabs}
\newcounter{measureNo}
\setcounter{measureNo}{1}
\newcommand\messwert[1][\stepcounter{MessNr}]{\theMessNr & lol & lol}
\newenvironment{measuretab}[3]
{\begin{tabularx}{|c|r|r|}
\hline
\multicolumn{3}{c}{THE TITLE}\\
\hline
\# & Zeit [ms] & Geschwindigkeit [\nicefrac{m}{s}]\\
\hline
}
{\end{tabularx}}
\begin{document}
\begin{measurtab}{Test 2110}
\value{0.0}{0.0}
\end{measuretab}
\end{document}
答案1
这个怎么样?
\documentclass{article}
\usepackage{nicefrac}
\newcommand*{\initrowcounter}{%
\newcounter{rowcounter}
\setcounter{rowcounter}{0}
}
\newcommand*\addrow[2]{%
\stepcounter{rowcounter}%
\therowcounter & #1 & #2\\%
}
\begin{document}
\initrowcounter{}
\begin{table}
\begin{tabular}{|c|r|r|}
\hline
\multicolumn{3}{c}{THE TITLE}\\
\hline
\# & Zeit [ms] & Geschwindigkeit [m/s]\\
\hline
\addrow{0.0}{0.0}
\addrow{0.5}{0.7}
\addrow{1.0}{1.2}
\addrow{1.5}{2.1}
\addrow{2.0}{2.5}
\hline
\end{tabular}
\end{table}
\end{document}