3

Adding \usepackage{xepersian} makes the following code produce an error:

\documentclass{article}

\usepackage{booktabs,caption,dcolumn}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}  
\usepackage{lmodern}
\usepackage[hidelinks]{hyperref}    
\usepackage{textcomp}
\usepackage[svgnames]{xcolor}
\usepackage[noabbrev,capitalize]{cleveref}      
\usepackage{amsthm}
\usepackage{thmtools}    
\usepackage{titlesec}       

\newcolumntype{d}[1]{D{.}{.}{4}}% column type for figures with 4 decimals
\newcommand{\subhead}[1]{\multicolumn{1}{c}{#1}}% to format sub-headings of d-type columns
\begin{document}
\begin{table}
  \centering
  \caption{Caption}
  \begin{tabular}{cd{4}d{4}d{4}d{4}d{4}d{4}}
    \toprule 
    \textbf{File}&                       \multicolumn{3}{c}{\textbf{Logistic Regression}}&                    \multicolumn{3}{c}{\textbf{Support Vector Machine}}\\
    \cmidrule(rl){2-4} \cmidrule(rl){5-7} 
                 & \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}& \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}\\ 
    \midrule
         100     &                0.0790&                0.1692&                   0.2945&                0.3670&                0.7187&                    3.1815\\
         101     &             -  0.8651&               50.0476&                   5.9384&             -  9.0714&              297.0923&                   46.2143\\
         102     &              124.2756&             - 50.9612&                 -14.2721&              128.2265&             -630.5455&                 -381.0930\\
         103     &                0.0357&                1.2473&                   0.2119&                0.3593&             -  0.2755&                    2.1764\\
         104     &             - 17.9048&             - 37.1111&                   8.8591&             - 30.7381&             -  9.5952&                 -  3.0000\\
         105     &              105.5518&              232.1160&                 -94.7351&              100.2497&              141.2778&                 -259.7326\\
   \bottomrule
 \end{tabular}
\end{table}
\end{document}

Is there a way to solve this problem?

2 Answers 2

3

There is an error in the definition of \newcolumntype with dcolumn, the correct syntax is \newcolumntype{d}[1]{D{.}{.}{#1}}

Using . as separator in the output with xepersian result an error???, you can replace it with \newcolumntype{d}[1]{D{.}{\mbox{.}}{#1}}.

\documentclass{article}

\usepackage{booktabs,caption,dcolumn}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}  
\usepackage{lmodern}
\usepackage[hidelinks]{hyperref}    
\usepackage{textcomp}
\usepackage[svgnames]{xcolor}
\usepackage[noabbrev,capitalize]{cleveref}      
\usepackage{amsthm}
\usepackage{thmtools}    
\usepackage{titlesec}  
\usepackage{xepersian} 
\settextfont{Amiri}    

\newcolumntype{d}[1]{D{.}{\mbox{.}}{#1}}% column type for figures with 4 decimals
\newcommand{\subhead}[1]{\multicolumn{1}{c}{#1}}% to format sub-headings of d-type columns

\begin{document}

\begin{latin}
\begin{table}
  \centering
  \caption{Caption}
  \begin{tabular}{cd{4}d{4}d{4}d{4}d{4}d{4}}
    \toprule 
    \textbf{File}&                       \multicolumn{3}{c}{\textbf{Logistic Regression}}&                    \multicolumn{3}{c}{\textbf{Support Vector Machine}}\\
    \cmidrule(rl){2-4} \cmidrule(rl){5-7} 
                 & \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}& \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}\\ 
    \midrule
         100     &                0.0790&                0.1692&                   0.2945&                0.3670&                0.7187&                    3.1815\\
         101     &             -  0.8651&               50.0476&                   5.9384&             -  9.0714&              297.0923&                   46.2143\\
         102     &              124.2756&             - 50.9612&                 -14.2721&              128.2265&             -630.5455&                 -381.0930\\
         103     &                0.0357&                1.2473&                   0.2119&                0.3593&             -  0.2755&                    2.1764\\
         104     &             - 17.9048&             - 37.1111&                   8.8591&             - 30.7381&             -  9.5952&                 -  3.0000\\
         105     &              105.5518&              232.1160&                 -94.7351&              100.2497&              141.2778&                 -259.7326\\
   \bottomrule
 \end{tabular}
\end{table}
\end{latin}
\end{document}

Result

enter image description here

3

The xepersian package makes . into a math active character, in order to fix the order of digits, I guess.

You can define a “normal” version of the period in math mode by

\DeclareMathSymbol{\decimalperiod}{\mathord}{letters}{"3A}

However, you have also to include the tabular in a latin environment. I also fixed the order of package loading (removing the useless lmodern).

\documentclass{article}

\usepackage{fontspec}
\usepackage{booktabs,caption,dcolumn}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage[svgnames]{xcolor}
\usepackage[hidelinks]{hyperref}
\usepackage[noabbrev,capitalize]{cleveref}

\usepackage{xepersian} 
\settextfont{Amiri}    

\DeclareMathSymbol{\decimalperiod}{\mathord}{letters}{"3A}

\newcolumntype{d}[1]{D{.}{\decimalperiod}{4}}% column type for figures with 4 decimals
\newcommand{\subhead}[1]{\multicolumn{1}{c}{#1}}% to format sub-headings of d-type columns

\begin{document}

\begin{table}
  \centering
  \caption{Caption}
\begin{latin}
  \begin{tabular}{cd{4}d{4}d{4}d{4}d{4}d{4}}
    \toprule 
    \textbf{File}&                       \multicolumn{3}{c}{\textbf{Logistic Regression}}&                    \multicolumn{3}{c}{\textbf{Support Vector Machine}}\\
    \cmidrule(rl){2-4} \cmidrule(rl){5-7} 
                 & \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}& \subhead{Sensitivity}& \subhead{Specificity}& \subhead{Total accuracy}\\ 
    \midrule
         100     &                0.0790&                0.1692&                   0.2945&                0.3670&                0.7187&                    3.1815\\
         101     &             -  0.8651&               50.0476&                   5.9384&             -  9.0714&              297.0923&                   46.2143\\
         102     &              124.2756&             - 50.9612&                 -14.2721&              128.2265&             -630.5455&                 -381.0930\\
         103     &                0.0357&                1.2473&                   0.2119&                0.3593&             -  0.2755&                    2.1764\\
         104     &             - 17.9048&             - 37.1111&                   8.8591&             - 30.7381&             -  9.5952&                 -  3.0000\\
         105     &              105.5518&              232.1160&                 -94.7351&              100.2497&              141.2778&                 -259.7326\\
   \bottomrule
 \end{tabular}
\end{latin}
\end{table}
\end{document}

enter image description here

With siunitx instead of dcolumn you get a better result, without any issue from .

\documentclass{article}

\usepackage{fontspec}
\usepackage{booktabs,caption,siunitx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{amsthm}
\usepackage{thmtools}
\usepackage{titlesec}
\usepackage{textcomp}
\usepackage[svgnames]{xcolor}
\usepackage[hidelinks]{hyperref}
\usepackage[noabbrev,capitalize]{cleveref}

\usepackage{xepersian} 
\settextfont{Amiri}    

\newcommand{\subhead}[1]{\multicolumn{1}{c}{#1}}% to format sub-headings of d-type columns

\begin{document}

\begin{table}
\centering
\caption{Caption}

\begin{latin}
\begin{tabular}{
 @{}
 l
 S[table-format=-2.4]
 S[table-format=-2.4]
 S[table-format=-2.4]
 S[table-format=-2.4]
 S[table-format=-3.4]
 S[table-format=-3.4]
 @{}
}
\toprule 
\textbf{File} &
  \multicolumn{3}{c}{\textbf{Logistic Regression}} &
  \multicolumn{3}{c}{\textbf{Support Vector Machine}} \\
\cmidrule(rl){2-4} \cmidrule(rl){5-7} 
&
  \subhead{Sensitivity} &
  \subhead{Specificity} &
  \subhead{Total accuracy} &
  \subhead{Sensitivity} &
  \subhead{Specificity}&
  \subhead{Total accuracy} \\
\midrule
100 &   0.0790 &   0.1692 &   0.2945 &   0.3670 &    0.7187 &    3.1815 \\
101 &  -0.8651 &  50.0476 &   5.9384 &  -9.0714 &  297.0923 &   46.2143 \\
102 & 124.2756 & -50.9612 & -14.2721 & 128.2265 & -630.5455 & -381.0930 \\
103 &   0.0357 &   1.2473 &   0.2119 &   0.3593 &   -0.2755 &    2.1764 \\
104 & -17.9048 & -37.1111 &   8.8591 & -30.7381 &   -9.5952 &   -3.0000 \\
105 & 105.5518 & 232.1160 & -94.7351 & 100.2497 &  141.2778 & -259.7326 \\
\bottomrule
\end{tabular}
\end{latin}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .