2

AI'm having trouble using the dcolumn decimal format, The file looks like this:enter image description here

But as soon as I add the formatting in the tabular* in \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{4}{d{3.6}} @{}} it wont compile and points to a missing } which is not the case unless I should add and extra one. If I understood correctly the formatting *{4}{d{3.6}} should give 4 columns 3 spaces before the decimal period and 6 after the decimal period to give space for the order of magnitude. Some of my code is based on the first answer to this question.


EDIT: This example had errors unrelated to the behavior of dcolumn as pointed by @Rmano. Each circuitikz environment was lacking a semicolon ; at the end of the last line. A better MWE was provided by @David Carlisle in the comments and his answer below.

\documentclass[letter]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-tabla]{babel}
\usepackage{mathrsfs}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{tikz}
\usepackage[oldvoltagedirection]{circuitikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\usetikzlibrary{arrows}
\pagestyle{empty}

\usepackage{booktabs}
\usepackage{caption}
\usepackage{subcaption}
\captionsetup{  singlelinecheck=false,
        font=footnotesize,
        labelfont=bf}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\title{\textbf{Impedancia}}
\author{}
\date{}

\begin{document}

\maketitle
\section{Circuitos RC}  

    \begin{figure}[ht]
        \centering
        \begin{subfigure}[t]{0.32\textwidth}
            \centering
            \begin{circuitikz}[scale=0.7, transform shape,font=\small]
            \draw (0,2)
            to[R=$R_s$, o-] (2,2)
            to[C= $C_s$] (2,0)
            to[short, -o] (0,0)
            \end{circuitikz}    
        \label{fig:a}
        \end{subfigure}
        \begin{subfigure}[t]{0.32\textwidth}
            \centering
            \begin{circuitikz}[scale=0.7, transform shape,font=\small]
            \draw (0,2) to[short, o-] (2,2)
            to[short] (4,2)
            to[C= $C_p$] (4,0)
            to[short, -o] (0,0)
            (2,2) to[R= $R_p$] (2,0)
            \end{circuitikz}    
        \label{fig:b}
        \end{subfigure}
        \begin{subfigure}[t]{0.32\textwidth}
            \centering
            \begin{circuitikz}[scale=0.7, transform shape,font=\small]
            \draw (0,2) to[R=$R_s$,o-] (2,2)
            to[short] (4,2)
            to[C= $C_p$] (4,0)
            to[short, -o] (0,0)
            (2,2) to[R= $R_p$] (2,0)
            \end{circuitikz}    
        \label{fig:c}%
        \end{subfigure}
\caption{a) Circuito RC serie. b) Circuito RC paralelo. c) Circuito RC paralelo con resistencia en serie. $R_s=R_p=1k\Omega$, $C_s=C_p=1\mu F$}
\label{fig:RC}%
\end{figure}


\section{Cálculos de Impedancia}    
\begin{table}[h]
    \footnotesize
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{4}{d{3.6}} @{}}
        \toprule
    & \multicolumn{4}{l}{\textit{Frecuencia}} \\
    & \multicolumn{1}{l}{$10 Hz$} & \multicolumn{1}{l}{$100 Hz$} & \multicolumn{1}{l}{$1 kHz$} & \multicolumn{1}{l}{$10 kHz$} \\
    \midrule
    \multicolumn{5}{l}{\textit{Circuito 1}} \\
    $Z_1 (\Omega)$  & 1.59e+04 & 1.88e+03 & 1.01e+03 & 1.00e+03 \\
    $\theta_1$  & -86.40 & -57.86 & -9.04 & -0.91 \\
    \multicolumn{5}{l}{\textit{Circuito 2}} \\
    $Z_2 (\Omega)$  & 1.00e+03 & 0.85.e+03 & 0.16e+03 & 1.59e+01 \\
    $\theta_2$  & -3.60 & -32.14 & -80.96 & -89.09 \\
    \multicolumn{5}{l}{\textit{Circuito 3}} \\
    $Z_3 (\Omega)$  & 2.00e+03 & 1.78e+03 & 1.03e+03 & 1.00e+03 \\
    $\theta_3$  & -1.80 & -14.70 & -8.61 & -0.91 \\
    \bottomrule
    \end{tabular*}
    \caption{Impedancia y ángulo de fase versus frecuencia}
\end{table}

\end{document}
8
  • You can try to remove the circuitikz and see if the problem persists....
    – Rmano
    Mar 18 at 22:47
  • Yes, I did it and it just works. But in this example I will have to replace {@{\extracolsep{\fill}} l *{4}{d{3.6}} @{}} with {@{\extracolsep{\fill}} lllll @{}}that seems to compile just fine without decimal alignment. Mar 18 at 23:11
  • 1
    the posted code gives the error ! Package tikz Error: Giving up on this path. Did you forget a semicolon?. Mar 18 at 23:34
  • 1
    I get an identical error if I delete the table environment and the loading of dcolumn, so the error shown is completely unrelated to dcolumn as the message indicates there should be a semicolon after to[short, -o] (0,0) Mar 18 at 23:36
  • 1
    I flagged my question for edition. I will edit it as soon as I have the shorter MWE that reproduces the problem with more clarity. Thanks for the comments. Mar 19 at 0:33

1 Answer 1

2

A simpler example not showing unrelated errors is

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}


\noindent
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l d{3.6} @{}}
    a & 1.59e+04 
\end{tabular*}
\end{document}

Which produces

! Missing } inserted.
<inserted text> 
                }
l.10     a & 1
              .59e+04
? 

the spanish option modifies . you can prevent that with

\documentclass{article}
\usepackage[spanish,es-nodecimaldot]{babel}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}


\noindent
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l d{3.6} @{}}
    a & 1.59e+04 
\end{tabular*}
\end{document}

If you need the spanish decimaldot option but just a normal . here, I couldn't see a defined way (the usual babel \shorhandoff mechanism to locally disable changes dos not work for this definition)

1
  • Thanks for your help. You are right, also learned that the [spanish]{babel}` package uses by default the colon, for decimal separation following the spanish language standard stablished by RAE, while [ensglish]{babel} follows the english standard which is the period. I marked your answer, and will leave the question as is with an edit pointing to read the comments as it might be helpful for other users of the forum. Mar 19 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.