. Advertisement .
..3..
. Advertisement .
..4..
I am working on programs, but I found the following warning message:
Illegal unit of measure (pt inserted).
\protect l.1545 & [errormessage]#92;ang{40}$ & 0.52 & 0.44 & 0.27 & 0.10 & -0.01 \ Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume that you meant to say pt, for printer's points. To recover gracefully from this error, it's best to delete the erroneous units; e.g., type `2' to delete two letters. (See Chapter 27 of The TeXbook.)
! Illegal unit of measure (pt inserted). \protect l.1545 ... & [errormessage]#92;ang{40}$ & 0.52 & 0.44 & 0.27 & 0.10 & -0.01 \ Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume that you meant to say pt, for printer's points. To recover gracefully from this error, it's best to delete the erroneous units; e.g., type `2' to delete two letters. (See Chapter 27 of The TeXbook.)
Is there any way to stabilize the issue “illegal unit of measure (pt inserted)”?
I read a lot of topics about this, but all of them were trying to install anything. Is this the correct way, or any recommendation for me?
Please find the beginning command below:
\newcommand*{\MinNumber}{0}%
\newcommand*{\MaxNumber}{1.2}%
\pgfmathsetmacro{\MidNumber}{(0.8}%
\def\test#1{\ifdim#1pt>\MidNumber\textcolor{gray!70}{#1}\else{#1}\fi}
\newcommand{\ApplyGradient}[2]{\centering %
\pgfmathsetmacro{\PercentColor}{100.0*(#1-\MinNumber)/(\MaxNumber-\MinNumber)}%
\edef\x{\noexpand\cellcolor{black!\PercentColor}}\x\test{#1}
}
\newcolumntype{R}{>{\collectcell\ApplyGradient}p{1.1cm}<{\endcollectcell}}
\newcolumntype{S}{>{\collectcell\ApplyGradient}p{0.6cm}<{\endcollectcell}}
%
\begin{table}[!ht]
\centering
\small
% \renewcommand{\arraystretch}{0.9}
% \begin{adjustbox}{width=0.8\textwidth}
\begin{tabular}{>{\centering}p{1.3cm}|>{\centering}p{0.9cm}|R R R R R }
\multicolumn{2}{c}{testing in[codesample]#92;rightarrow$}& \multicolumn{1}{c} {[codesample]#92;ang{40}$} & \multicolumn{1}{c} {[codesample]#92;ang{20}$} & \multicolumn{1}{c} {[codesample]#92;ang{0}$} & \multicolumn{1}{c} {$-\ang{20}$} & \multicolumn{1}{c} {$-\ang{40}$} \\ \midrule
& [codesample]#92;ang{40}$ & 0.52 & 0.44 & 0.27 & 0.10 & -0.01 \\
& [codesample]#92;ang{20}$ & 0.47 & 0.49 & 0.35 & 0.19 & 0.07 \\
spider9 & [codesample]#92;ang{0}$ & 0.25 & 0.47 & 0.63 & 0.46 & 0.24 \\
& $-\ang{20}$ & 0.05 & 0.17 & 0.35 & 0.55 & 0.54 \\
& $-\ang{40}$ & 0.0 & 0.05 & 0.21 & 0.47 & 0.77 \\
\midrule
& [codesample]#92;ang{40}$ & 0.75 & 0.69 & 0.40 & 0.17 & 0.04 \\
& [codesample]#92;ang{20}$ & 0.72 & 0.82 & 0.59 & 0.30 & 0.10 \\
gecko7 & [codesample]#92;ang{0}$ & 0.31 & 0.65 & 1.06 & 0.96 & 0.56 \\
& $-\ang{20}$ & 0.16 & 0.45 & 0.86 & 1.18 & 0.98 \\
& $-\ang{40}$ & 0.03 & 0.15 & 0.40 & 0.74 & 0.96 \\
\midrule
& [codesample]#92;ang{40}$ & 1.09 & 0.75 & 0.39 & 0.14 & 0.02 \\
& [codesample]#92;ang{20}$ & 0.54 & 0.55 & 0.33 & 0.15 & 0.04 \\
babyA & [codesample]#92;ang{0}$ & 0.29 & 0.58 & 0.88 & 0.74 & 0.42 \\
& $-\ang{20}$ & 0.18 & 0.47 & 0.85 & 1.09 & 0.71 \\
& $-\ang{40}$ & 0.02 & 0.11 & 0.33 & 0.65 & 0.91 \\
\bottomrule
\end{tabular}
%
\begin{tabular}{p{0.4cm} S}
& 0.0 \\
& 0.1 \\
& 0.2 \\
& 0.3 \\
& 0.4 \\
& 0.5 \\
& 0.6 \\
& 0.7 \\
& 0.8 \\
& 0.9 \\
& 1.0 \\
& 1.1 \\
& 1.2 \\
\end{tabular}
% \end{adjustbox}
\caption{Robustness of the top learned controllers for different directions in the real world.
The data shows the fitness that the top controllers of three robots in 5 directions (the second column) perform in another directions (the first row).
The fitness value in a cell is averaged over three controller and three repetitions for each controller.
The dark and light color represent the high and low fitness value respectively.}
\label{tab:robustness}
\end{table}
These are some things to consider:
You must ensure that both
It is awkward to combine
......... ADVERTISEMENT ......... ..8..
\MinNumber
is 0
but you can have a -0.01
number.
<dimA>
(\ifdim <dimA><relation><dimB>
), and <dimB>
(<dimB>
) are dimensioned if you want to perform a dim
ensions test. You have
\ifdim#1pt>\MidNumber
\MidNumber
is not a dimension. It’s just a number (0.8
). This is the root cause of the problem.
\ApplyGradient
should take only one argument and not two.
booktabs
with vertical rules in tabular
. They are not necessary; they have been retained in the output.
\documentclass{article}
\usepackage[margin=1in]{geometry}% Just for this example
\usepackage[table]{xcolor}
\usepackage{booktabs,collcell,xfp}
\newcommand*{\ang}[2]{#1^\circ}
\newcommand*{\MinNumber}{-0.01}%
\newcommand*{\MaxNumber}{1.2}%
\newcommand*{\MidNumber}{0.8}%
\newcommand{\test}[2]{\ifdim#1pt>\MidNumber pt\textcolor{gray!70}{#1}\else #1\fi}
\newcommand{\ApplyGradient}[2]{\centering %
\edef\x{\noexpand\cellcolor{black!\fpeval{100*(#1-\MinNumber)/(\MaxNumber-\MinNumber)}}}\x\test{#1}
}
\newcolumntype{R}{>{\collectcell\ApplyGradient}p{1.1cm}<{\endcollectcell}}
\newcolumntype{S}{>{\collectcell\ApplyGradient}p{0.6cm}<{\endcollectcell}}
%
\begin{document}
\begin{table}
\centering
\begin{tabular}{
>{\centering}p{1.3cm} |
>{\centering}p{0.9cm} |
*{5}{R}
}
\multicolumn{2}{c}{testing in$\rightarrow$} &
\multicolumn{1}{c}{$\ang{40}$} &
\multicolumn{1}{c}{$\ang{20}$} &
\multicolumn{1}{c}{$\ang{0}$} &
\multicolumn{1}{c}{$-\ang{20}$} &
\multicolumn{1}{c}{$-\ang{40}$} \\
\midrule
& $\ang{40}$ & 0.52 & 0.44 & 0.27 & 0.10 & -0.01 \\
& $\ang{20}$ & 0.47 & 0.49 & 0.35 & 0.19 & 0.07 \\
spider9 & $\ang{0}$ & 0.25 & 0.47 & 0.63 & 0.46 & 0.24 \\
& $-\ang{20}$ & 0.05 & 0.17 & 0.35 & 0.55 & 0.54 \\
& $-\ang{40}$ & 0.0 & 0.05 & 0.21 & 0.47 & 0.77 \\
\midrule
& $\ang{40}$ & 0.75 & 0.69 & 0.40 & 0.17 & 0.04 \\
& $\ang{20}$ & 0.72 & 0.82 & 0.59 & 0.30 & 0.10 \\
gecko7 & $\ang{0}$ & 0.31 & 0.65 & 1.06 & 0.96 & 0.56 \\
& $-\ang{20}$ & 0.16 & 0.45 & 0.86 & 1.18 & 0.98 \\
& $-\ang{40}$ & 0.03 & 0.15 & 0.40 & 0.74 & 0.96 \\
\midrule
& $\ang{40}$ & 1.09 & 0.75 & 0.39 & 0.14 & 0.02 \\
& $\ang{20}$ & 0.54 & 0.55 & 0.33 & 0.15 & 0.04 \\
babyA & $\ang{0}$ & 0.29 & 0.58 & 0.88 & 0.74 & 0.42 \\
& $-\ang{20}$ & 0.18 & 0.47 & 0.85 & 1.09 & 0.71 \\
& $-\ang{40}$ & 0.02 & 0.11 & 0.33 & 0.65 & 0.91 \\
\bottomrule
\end{tabular}
\hspace{4mm}
\begin{tabular}{ S }
0.0 \\ 0.1 \\ 0.2 \\ 0.3 \\ 0.4 \\ 0.5 \\
0.6 \\ 0.7 \\ 0.8 \\ 0.9 \\ 1.0 \\ 1.1 \\
1.2
\end{tabular}
\caption{Robustness of the top learned controllers for different directions in the real world.
The data shows the fitness that the top controllers of three robots in~5 directions (the second column) perform in another directions (the first row).
The fitness value in a cell is averaged over three controller and three repetitions for each controller.
The dark and light color represent the high and low fitness value respectively.}
\end{table}
\end{document}