2

I have a LaTeX document that gives me the following error:

! Argument of \@xs@IfStrEq@@ has an extra }.

The document is as follows:

\documentclass{article}


%PAQUETES
%\usepackage[arial,utf8]{coolfont}
\usepackage[fasterrors,graphics]{ucs} % para archivos en formato utf8
\usepackage{inputenc} % letras tal cual: ñ, á, etc.
\usepackage[scaled]{uarial} % fuente arial
%\usepackage{lmodern} % fuentes tipo 1
\usepackage{ifthen,ifpdf,parskip,arrayjobx,xstring,xintexpr}
\usepackage{geometry}


%DEFINICIONES
\newcommand{\dec}{1}
\newcommand{\setDec}[1]{\renewcommand{\dec}{#1}}
\newcommand{\idiActivo}{es}
\newcommand{\setIdiActivo}[1]{\renewcommand{\idiActivo}{#1}}

% Procedimiento en castellano
\newarray\procedimientoEs
\procedimientoEs(1)={procedimento de provisión de puestos\xspace}%autonómico m
\procedimientoEs(2)={PROCEDIMENTO DE PROVISIÓN DE PUESTOS\xspace}%autonómico y
\procedimientoEs(3)={Procedimento de Provisión de Puestos\xspace}%autonómico t
\procedimientoEs(4)={Procedimento de provisión de puestos\xspace}%autonómico f
\procedimientoEs(5)={concurso de traslados\xspace}%nacional m
\procedimientoEs(6)={CONCURSO DE TRASLADOS\xspace}%nacional y
\procedimientoEs(7)={Concurso de Traslados\xspace}%nacional t
\procedimientoEs(8)={Concurso de traslados\xspace}%nacional f

% Procedimiento en valenciano.
\newarray\procedimientoVa
\procedimientoVa(1)={procediment de provisió de llocs de treball\xspace}%autonómico m
\procedimientoVa(2)={PROCEDIMENT DE PROVISIÓ DE LLOCS DE TREBALL\xspace}%autonómico y
\procedimientoVa(3)={Procediment de Provisió de Llocs de Treball\xspace}%autonómico t
\procedimientoVa(4)={Procediment de provisió de llocs de treball\xspace}%autonómico f
\procedimientoVa(5)={concurs de trasllats\xspace}%nacional m
\procedimientoVa(6)={CONCURS DE TRASLLATS\xspace}%nacional y
\procedimientoVa(7)={Concurs de Trasllats\xspace}%nacional t
\procedimientoVa(8)={Concurs de trasllats\xspace}%nacional f

% Concurso actual
\newcommand{\concursoAct}{A}% valores posibles: A, N
\newcommand{\setConcursoAct}[1]{\renewcommand{\concursoAct}{#1}}

% Concurso anterior
\newcommand{\concursoAnt}{%
  \IfStrEqCase{\concursoAct}{%
    {A}{N}%
    {N}{A}%
  }%
}

\newcommand{\procAnt}[1][m]{%#1: modo
  \IfStrEqCase{\idiActivo}{%
  {es}{\IfStrEqCase{\concursoAnt}{%
       {A}{\IfStrEqCase{#1}{%
           {m}{\procedimientoEs(1)}%
           {y}{\procedimientoEs(2)}%
           {t}{\procedimientoEs(3)}%
           {f}{\procedimientoEs(4)}%
           }%
          }%
       {N}{\IfStrEqCase{#1}{%
           {m}{\procedimientoEs(5)}%
           {y}{\procedimientoEs(6)}%
           {t}{\procedimientoEs(7)}%
           {f}{\procedimientoEs(8)}%
           }%
          }%
       }%
      }%
  {va}{\IfStrEqCase{\concursoAnt}{%
       {A}{\IfStrEqCase{#1}{%
           {m}{\procedimientoVa(1)}%
           {y}{\procedimientoVa(2)}%
           {t}{\procedimientoVa(3)}%
           {f}{\procedimientoVa(4)}%
           }%
          }%
       {N}{\IfStrEqCase{#1}{%
           {m}{\procedimientoVa(5)}%
           {y}{\procedimientoVa(6)}%
           {t}{\procedimientoVa(7)}%
           {f}{\procedimientoVa(8)}%
           }%
          }%
       }%
      }%
  }%
}


%CONFIGURACION
\renewcommand{\familydefault}{\sfdefault}
\inputencoding{utf8x}
\geometry{a4paper,bindingoffset=0pt,margin=1in,headsep=.5in}


%DOCUMENTO
\begin{document}
\concursoAnt

\procAnt
\end{document}

I don't know where the error can be. Any help is welcomed

2
  • 1
    Your problem are nested xstring-tests. See tex.stackexchange.com/questions/68623/… for example.
    – musicman
    Oct 19, 2015 at 9:27
  • You are trying to compare \concursoAnt with A or N, but it is neither, because it is the set of instructions necessary to produce either A or N.
    – egreg
    Oct 19, 2015 at 9:29

1 Answer 1

2

You're trying to compare \concursoAnt with A or N, but it is

\newcommand{\concursoAnt}{%
  \IfStrEqCase{\concursoAct}{%
    {A}{N}%
    {N}{A}%
  }%
}

which means it is a set of instructions to produce either A or N.

Here's a possible solution: the \concursoAnt macro defines a new macro and it is called as the first step in \procAnt.

\documentclass{article}

%PAQUETES
\usepackage[utf8]{inputenc} % letras tal cual: ñ, á, etc.
\usepackage{ifthen,ifpdf,parskip,arrayjobx,xstring,xintexpr}

%DEFINICIONES
\newcommand{\dec}{1}
\newcommand{\setDec}[1]{\renewcommand{\dec}{#1}}
\newcommand{\idiActivo}{es}
\newcommand{\setIdiActivo}[1]{\renewcommand{\idiActivo}{#1}}

% Procedimiento en castellano
\newarray\procedimientoEs
\procedimientoEs(1)={procedimento de provisión de puestos}%autonómico m
\procedimientoEs(2)={PROCEDIMENTO DE PROVISIÓN DE PUESTOS}%autonómico y
\procedimientoEs(3)={Procedimento de Provisión de Puestos}%autonómico t
\procedimientoEs(4)={Procedimento de provisión de puestos}%autonómico f
\procedimientoEs(5)={concurso de traslados}%nacional m
\procedimientoEs(6)={CONCURSO DE TRASLADOS}%nacional y
\procedimientoEs(7)={Concurso de Traslados}%nacional t
\procedimientoEs(8)={Concurso de traslados}%nacional f

% Procedimiento en valenciano.
\newarray\procedimientoVa
\procedimientoVa(1)={procediment de provisió de llocs de treball}%autonómico m
\procedimientoVa(2)={PROCEDIMENT DE PROVISIÓ DE LLOCS DE TREBALL}%autonómico y
\procedimientoVa(3)={Procediment de Provisió de Llocs de Treball}%autonómico t
\procedimientoVa(4)={Procediment de provisió de llocs de treball}%autonómico f
\procedimientoVa(5)={concurs de trasllats}%nacional m
\procedimientoVa(6)={CONCURS DE TRASLLATS}%nacional y
\procedimientoVa(7)={Concurs de Trasllats}%nacional t
\procedimientoVa(8)={Concurs de trasllats}%nacional f

% Concurso actual
\newcommand{\concursoAct}{A}% valores posibles: A, N
\newcommand{\setConcursoAct}[1]{\renewcommand{\concursoAct}{#1}}

% Concurso anterior
\newcommand{\concursoAnt}{%
  \IfStrEqCase{\concursoAct}{%
    {A}{\def\concursoValue{N}}%
    {N}{\def\concursoValue{A}}%
  }%
}

\newcommand{\procAnt}[1][m]{%#1: modo
  \concursoAnt % set \concursoValue
  \IfStrEqCase{\idiActivo}{%
  {es}{\IfStrEqCase{\concursoValue}{%
       {A}{\IfStrEqCase{#1}{%
           {m}{\procedimientoEs(1)}%
           {y}{\procedimientoEs(2)}%
           {t}{\procedimientoEs(3)}%
           {f}{\procedimientoEs(4)}%
           }%
          }%
       {N}{\IfStrEqCase{#1}{%
           {m}{\procedimientoEs(5)}%
           {y}{\procedimientoEs(6)}%
           {t}{\procedimientoEs(7)}%
           {f}{\procedimientoEs(8)}%
           }%
          }%
       }%
      }%
  {va}{\IfStrEqCase{\concursoValue}{%
       {A}{\IfStrEqCase{#1}{%
           {m}{\procedimientoVa(1)}%
           {y}{\procedimientoVa(2)}%
           {t}{\procedimientoVa(3)}%
           {f}{\procedimientoVa(4)}%
           }%
          }%
       {N}{\IfStrEqCase{#1}{%
           {m}{\procedimientoVa(5)}%
           {y}{\procedimientoVa(6)}%
           {t}{\procedimientoVa(7)}%
           {f}{\procedimientoVa(8)}%
           }%
          }%
       }%
      }%
  }%
}

%DOCUMENTO
\begin{document}

\procAnt

\procAnt[y]

\procAnt[t]

\procAnt[f]

\setConcursoAct{N}

\procAnt

\procAnt[y]

\procAnt[t]

\procAnt[f]

\end{document}

enter image description here

Note that I removed ucs in favor of utf8. In any case you must set the input encoding before defining the strings, or the translation from UTF-8 to LaTeX commands will not work.


Here's a different interface, using expl3.

\documentclass{article}

%PAQUETES
\usepackage[utf8]{inputenc} % letras tal cual: ñ, á, etc.
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\concurso}{O{}m}
 {
  \group_begin:
  \keys_set:nn { delgado/concurso } { #1 }
  \delgado_print_competition_title:n { #2 }
  \group_end:
 }

\keys_define:nn { delgado/concurso }
 {
  language .tl_set:N   = \l_delgado_competition_language_tl,
  local    .bool_set:N = \l_delgado_competition_national_bool,
  local    .default:n  = false,
  national .bool_set:N = \l_delgado_competition_national_bool,
  national .default:n  = true,
  language .initial:n  = es,
  national .initial:n  = true,
 }

\prop_new:N \g_delgado_competition_titles_prop

% Procedimiento en castellano
\prop_gput:Nnn \g_delgado_competition_titles_prop { es a m }
 {procedimento ~ de ~ provisión ~ de ~ puestos}%autonómico m
\prop_gput:Nnn \g_delgado_competition_titles_prop { es a y }
 {PROCEDIMENTO ~ DE ~ PROVISIÓN ~ DE ~ PUESTOS}%autonómico y
\prop_gput:Nnn \g_delgado_competition_titles_prop { es a t }
 {Procedimento ~ de ~ Provisión ~ de ~ Puestos}%autonómico t
\prop_gput:Nnn \g_delgado_competition_titles_prop { es a f }
 {Procedimento ~ de ~ provisión ~ de ~ puestos}%autonómico f
\prop_gput:Nnn \g_delgado_competition_titles_prop { es n m }
 {concurso ~ de ~ traslados}%nacional m
\prop_gput:Nnn \g_delgado_competition_titles_prop { es n y }
 {CONCURSO ~ DE ~ TRASLADOS}%nacional y
\prop_gput:Nnn \g_delgado_competition_titles_prop { es n t }
 {Concurso ~ de ~ Traslados}%nacional t
\prop_gput:Nnn \g_delgado_competition_titles_prop { es n f }
 {Concurso ~ de ~ traslados}%nacional f

% Procedimiento en valenciano
\prop_gput:Nnn \g_delgado_competition_titles_prop { va a m }
 {procediment ~ de ~ provisió ~ de ~ llocs ~ de ~ treball}%autonómico m
\prop_gput:Nnn \g_delgado_competition_titles_prop { va a y }
 {PROCEDIMENT ~ DE ~ PROVISIÓ ~ DE ~ LLOCS ~ DE ~ TREBALL}%autonómico y
\prop_gput:Nnn \g_delgado_competition_titles_prop { va a t }
 {Procediment ~ de ~ Provisió ~ de ~ Llocs ~ de ~ Treball}%autonómico t
\prop_gput:Nnn \g_delgado_competition_titles_prop { va a f }
 {Procediment ~ de ~ provisió ~ de ~ llocs ~ de ~ treball}%autonómico f
\prop_gput:Nnn \g_delgado_competition_titles_prop { va n m }
 {concurs ~ de ~ trasllats}%nacional m
\prop_gput:Nnn \g_delgado_competition_titles_prop { va n y }
 {CONCURS ~ DE ~ TRASLLATS}%nacional y
\prop_gput:Nnn \g_delgado_competition_titles_prop { va n t }
 {Concurs ~ de ~ Trasllats}%nacional t
\prop_gput:Nnn \g_delgado_competition_titles_prop { va n f }
 {Concurs ~ de ~ trasllats}%nacional f

\cs_new_protected:Nn \delgado_print_competition_title:n
 {
  \prop_get:Nx \g_delgado_competition_titles_prop
   {
    \l_delgado_competition_language_tl % language string
    \bool_if:NTF \l_delgado_competition_national_bool { n } { a } % local or national
    #1 % mytf
   }
 }
\cs_generate_variant:Nn \prop_get:Nn { Nx }
\ExplSyntaxOff

%DOCUMENTO
\begin{document}

\concurso{m}

\concurso{y}

\concurso{t}

\concurso{f}

\concurso[local]{m}

\concurso[local,language=va]{y}

\end{document}

enter image description here

3
  • xstring-tests are never expandable, are they? I tried something very similar with \edef\concursoAnt{\IfStrEqCase{\concursoAct}{......
    – musicman
    Oct 19, 2015 at 11:59
  • 1
    @musicman No, they aren't. It's exactly the problem, because \IfStrEqCase performs \edef to its first two arguments.
    – egreg
    Oct 19, 2015 at 12:00
  • musicman thank you very much for your comments, which clarify me the underlying problem. Oct 20, 2015 at 8:13

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.