
我的目標是創建一個命令來存儲數字並在表中計算。
\begin{table}[h]
\npthousandsep{,}
\STautoround*{0}
\begin{spreadtab}{{tabular}{| l | r | r | r |}} \hline
& @\textbf{Current Arrangement} & @\textbf{New Arrangement} & @\textbf{Difference} \\ \hline
@Base Salary (SGD) & 50000.00 & 60000.00 & c2-b2\\ \hline
\end{spreadtab}
\end{table}
但由於某種原因,我必須從代碼中載入數字。例如,我用來\newcommand{\BASESALARYAMOUNT}{50,000.00}
替換部分錶格。由於 的存在,
,我習慣xstring
透過以下命令刪除它。但它不運行。
\newcommand{\BASESALARYAMOUNT}{50,000.00}
\newcommand{\basesalaryamountno}{\StrSubstitute{\BASESALARYAMOUNT{}}{,}{}}
\begin{table}[h]
\npthousandsep{,}
\STautoround*{0}
\begin{spreadtab}{{tabular}{| l | r | r | r |}} \hline
& @\textbf{Current Arrangement} & @\textbf{New Arrangement} & @\textbf{Difference} \\ \hline
@Base Salary (SGD) & \BASESALARYAMOUNT & 60000.00 & c2-b2\\ \hline
\end{spreadtab}
\end{table}
有什麼解決辦法嗎?謝謝
答案1
stringstrings
如果我理解OP的問題,這是一種方法。該巨集\convertchar[q]{\BASESALARYAMOUNT}{,}{}
刪除逗號字元\BASESALARYAMOUNT
並將結果儲存起來\thestring
以供以後呼叫。
\documentclass{article}
\usepackage{spreadtab,numprint,stringstrings}
\begin{document}
\newcommand{\BASESALARYAMOUNT}{50,000.00}
\convertchar[q]{\BASESALARYAMOUNT}{,}{}
\begin{table}[h]
\npthousandsep{,}
\STautoround*{0}
\begin{spreadtab}{{tabular}{| l | r | r | r |}} \hline
& @\textbf{Current Arrangement} & @\textbf{New Arrangement} & @\textbf{Difference} \\ \hline
@Base Salary (SGD) & \thestring & 60000.00 & c2-b2\\ \hline
\end{spreadtab}
\end{table}
\end{document}
答案2
\newcommand{\basesalaryamountno}{\StrSubstitute{\BASESALARYAMOUNT{}}{,}{}}
我發現\StrDel{\BASESALARYAMOUNT{}}{,}[\baseamount]
可以解決問題,而不是使用。這可以刪除,
數字中的 並將新字串儲存在 中\baseamount
。