%%
%% This is file `elzcards.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% elzcards.dtx  (with options: `package')
%% 
%% Copyright 2019 Emilio Augusto Lazo Zaia <emiliolazozaia@gmail.com>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%  http://www.latex-project.org/lppl/lppl-1-3c.{html|txt|tex|pdf}
%% and the latest version of this license is in
%%  http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of
%% LaTeX version 2008/05/04 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Emilio Augusto Lazo Zaia.
%% 
%% This work consists of the files README and elzcards.dtx with
%% its derived files elzcards.ins, elzcards.sty and
%% elzcards-examples.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{elzcards}[2019/08/16 v1.60 ELZ cards]

\RequirePackage{calc}
\RequirePackage{xparse}
\RequirePackage{keyval}

\AtBeginDocument{\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}}

\newcommand{\PKGERROR}[1]{\PackageError{elzcards}{** #1. **}{}}
\newcommand{\PKGWARNING}[1]{\PackageWarning{elzcards}{** #1. **}{}}

\newif\if@elzc@cruces
\newif\if@elzc@segmentos
\newif\if@elzc@puntos
\newif\if@elzc@lineas
\newif\if@elzc@sinmarcas
\newif\if@elzc@autosep
\newif\if@elzc@autosepinterno
\newif\if@elzc@autoseptotal
\newif\if@elzc@columnasfilas
\newif\if@elzc@fichas
\newif\if@elzc@inicio
\newif\if@elzc@orden
\newif\if@elzc@calculaorden
\newif\if@elzc@ordentransverso
\newif\if@elzc@tarjetaconreverso
\newif\if@elzc@fichaconreverso
\newif\if@elzc@actualconreverso
\newif\if@elzc@procesareverso

\newlength{\elzc@TarjXdim}
\newlength{\elzc@TarjYdim}
\newlength{\elzc@SeparaX}
\newlength{\elzc@SeparaY}
\newlength{\elzc@TempLen}
\newlength{\elzc@TempUnitLength}
\newlength{\elzc@DefTPXdim}
\newlength{\elzc@DefTPYdim}
\newlength{\elzc@DefFichaXdim}
\newlength{\elzc@DefFichaYdim}
\newlength{\elzc@DefSeparaX}
\newlength{\elzc@DefSeparaY}
\newlength{\elzc@DefArista}
\newlength{\elzc@DefPunto}
\newlength{\elzc@DefLinea}

\newcounter{elzc@TarjXdim}
\newcounter{elzc@TarjYdim}
\newcounter{elzc@PapelX}
\newcounter{elzc@PapelY}
\newcounter{elzc@MatrizXo}
\newcounter{elzc@MatrizYo}
\newcounter{elzc@NumX}
\newcounter{elzc@NumY}
\newcounter{elzc@NumXY}
\newcounter{elzc@NumForzadoX}
\newcounter{elzc@NumForzadoY}
\newcounter{elzc@ContX}
\newcounter{elzc@ContY}
\newcounter{elzc@PosX}
\newcounter{elzc@PosY}
\newcounter{elzc@PosMarcaX}
\newcounter{elzc@PosMarcaY}
\newcounter{elzc@SeparaX}
\newcounter{elzc@SeparaY}
\newcounter{elzc@Punto}
\newcounter{elzc@Arista}
\newcounter{elzc@Fichas}
\newcounter{elzc@FichasEnOrden}
\newcounter{elzc@FichaActual}
\newcounter{elzc@FichaActualOrdenada}
\newcounter{elzc@ElementosOrden}
\newcounter{elzc@OrdenCiclo}
\newcounter{elzc@OrdenResto}
\newcounter{elzc@OrdenCicloDos}
\newcounter{elzc@TempNumX}
\newcounter{elzc@TempNumY}
\newcounter{elzc@Temp}
\newcounter{elzc@TempDos}

\def\elzc@aux@cruces{%
 \@elzc@crucestrue\@elzc@segmentostrue\@elzc@puntosfalse\@elzc@lineasfalse\@elzc@sinmarcasfalse}
\def\elzc@aux@segmentos{%
 \@elzc@crucesfalse\@elzc@segmentostrue\@elzc@puntosfalse\@elzc@lineasfalse\@elzc@sinmarcasfalse}
\def\elzc@aux@puntos{%
 \@elzc@crucesfalse\@elzc@segmentosfalse\@elzc@puntostrue\@elzc@lineasfalse\@elzc@sinmarcasfalse}
\def\elzc@aux@lineas{%
 \@elzc@crucesfalse\@elzc@segmentosfalse\@elzc@puntosfalse\@elzc@lineastrue\@elzc@sinmarcasfalse}
\def\elzc@aux@sinmarcas{%
 \@elzc@crucesfalse\@elzc@segmentosfalse\@elzc@puntosfalse\@elzc@lineasfalse\@elzc@sinmarcastrue}

\def\elzc@aux@autosep@interno{%
 \@elzc@autoseptrue\@elzc@autosepinternotrue\@elzc@autoseptotalfalse}
\def\elzc@aux@autosep@total{%
 \@elzc@autoseptrue\@elzc@autosepinternofalse\@elzc@autoseptotaltrue}
\def\elzc@aux@autosep@ninguno{%
 \@elzc@autosepfalse\@elzc@autosepinternofalse\@elzc@autoseptotalfalse}

\ExplSyntaxOn
 \cs_new:Npn \elzc@aux@elementosorden{
  \seq_set_split:NnV \l_tmpa_seq {~} {\elzc@Orden}
  \int_set:Nn \c@elzc@ElementosOrden {(\seq_count:N \l_tmpa_seq) -2}}

 \cs_new:Npn \elzc@aux@fichatransversa #1#2{
  \seq_set_split:NnV \l_tmpa_seq {~} {\elzc@Orden}
  \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l_tmpa_seq {#1+1}}
  \int_set:cn {c@#2} \l_tmpa_tl}
\ExplSyntaxOff

\define@key{ELZc}{hsize}{\setlength{\elzc@TarjXdim}{#1}}
\define@key{ELZc}{vsize}{\setlength{\elzc@TarjYdim}{#1}}
\define@key{ELZc}{columns}{\@elzc@columnasfilastrue\setcounter{elzc@NumForzadoX}{#1}}
\define@key{ELZc}{rows}{\@elzc@columnasfilastrue\setcounter{elzc@NumForzadoY}{#1}}
\define@key{ELZc}{hgap}{\elzc@aux@autosep@ninguno\setlength{\elzc@SeparaX}{#1}}
\define@key{ELZc}{vgap}{\elzc@aux@autosep@ninguno\setlength{\elzc@SeparaY}{#1}}
\define@key{ELZc}{autogap inner}[true]{\elzc@aux@autosep@interno}
\define@key{ELZc}{autogap total}[true]{\elzc@aux@autosep@total}
\define@key{ELZc}{no autogap}[true]{\elzc@aux@autosep@ninguno}
\define@key{ELZc}{segment length}{
 \setlength{\elzc@TempLen}{#1}\setcounter{elzc@Arista}{\elzc@TempLen}}
\define@key{ELZc}{dot size}{\setlength{\elzc@TempLen}{#1}\setcounter{elzc@Punto}{\elzc@TempLen}}
\define@key{ELZc}{line thickness}{\linethickness{#1}}
\define@key{ELZc}{crosses}[true]{\elzc@aux@cruces}
\define@key{ELZc}{segments}[true]{\elzc@aux@segmentos}
\define@key{ELZc}{dots}[true]{\elzc@aux@puntos}
\define@key{ELZc}{lines}[true]{\elzc@aux@lineas}
\define@key{ELZc}{no marks}[true]{\elzc@aux@sinmarcas}
\define@key{ELZc}{crop color}{\def\elzc@ColorMarcas{#1}}
\define@key{ELZc}{order}{
 \if@elzc@ordentransverso
  \PKGWARNING{Transverse ordering not available when order pattern is given}
  \@elzc@ordentransversofalse
 \fi
 \@elzc@ordentrue\@elzc@calculaordentrue\def\elzc@Orden{ #1 }\elzc@aux@elementosorden}
\define@key{ELZc}{transverse}[true]{
 \if@elzc@orden
  \PKGWARNING{Transverse ordering not available when order pattern is given}
 \else
  \@elzc@ordentransversotrue\@elzc@calculaordentrue
 \fi}
\define@key{ELZc}{no transverse}[true]{
 \@elzc@ordentransversofalse
 \if@elzc@orden\else\@elzc@calculaordenfalse\fi}

\NewDocumentCommand{\CurrentIC}{s}{%
  \IfBooleanTF{#1}{\arabic{elzc@FichaActual}}{\arabic{elzc@FichaActualOrdenada}}}
\let\CurrentFC\CurrentIC

\newcommand*{\TotalIC}{\arabic{elzc@Fichas}}
\let\TotalFC\TotalIC

\newcommand*{\BCdim}[2]{\setlength{\elzc@DefTPXdim}{#1}\setlength{\elzc@DefTPYdim}{#2}}
\newcommand*{\ICdim}[2]{\setlength{\elzc@DefFichaXdim}{#1}\setlength{\elzc@DefFichaYdim}{#2}}
\let\FCdim\ICdim

\NewDocumentCommand{\CardGap}{m g}{%
 \def\elzc@DefAutoSep{\elzc@aux@autosep@ninguno}%
 \setlength{\elzc@DefSeparaX}{#1}%
 \IfValueTF{#2}{\setlength{\elzc@DefSeparaY}{#2}}{\setlength{\elzc@DefSeparaY}{#1}}}

\newcommand*{\SegmentLength}[1]{\setlength{\elzc@DefArista}{#1}}
\newcommand*{\DotSize}[1]{\setlength{\elzc@DefPunto}{#1}}
\newcommand*{\LineThickness}[1]{\setlength{\elzc@DefLinea}{#1}}

\newcommand*{\CropCrosses}{\def\elzc@DefMarcasCorte{\elzc@aux@cruces}}
\newcommand*{\CropSegments}{\def\elzc@DefMarcasCorte{\elzc@aux@segmentos}}
\newcommand*{\CropDots}{\def\elzc@DefMarcasCorte{\elzc@aux@puntos}}
\newcommand*{\CropLines}{\def\elzc@DefMarcasCorte{\elzc@aux@lineas}}
\newcommand*{\CropColor}[1]{\def\elzc@DefColorMarcas{#1}}
\newcommand*{\NoCropMarks}{\def\elzc@DefMarcasCorte{\elzc@aux@sinmarcas}}

\newcommand*{\AutoGapInner}{\def\elzc@DefAutoSep{\elzc@aux@autosep@interno}}
\newcommand*{\AutoGapTotal}{\def\elzc@DefAutoSep{\elzc@aux@autosep@total}}
\newcommand*{\NoAutoGap}{\def\elzc@DefAutoSep{\elzc@aux@autosep@ninguno}}

\newcommand*{\Transverse}{%
 \def\elzc@DefTrasverso{\@elzc@ordentransversotrue\@elzc@calculaordentrue}}
\newcommand*{\NoTransverse}{%
 \def\elzc@DefTrasverso{\@elzc@ordentransversofalse\@elzc@calculaordenfalse}}

\NewDocumentCommand{\MakeBC}{s o}{%
 \ifx\undefined\@elzc@TarjetaAnverso
  \PKGERROR{There are no business cards defined}%
 \else
  \@elzc@fichasfalse
  \if@elzc@tarjetaconreverso\@elzc@actualconreversotrue\else\@elzc@actualconreversofalse\fi
  \elzc@Predeterminados
  \IfValueT{#2}{\setkeys{ELZc}{#2}}%
  \elzc@CicloCompleto
  \IfBooleanF{#1}{\elzc@TodoCero}%
 \fi}

\NewDocumentCommand{\MakeIC}{s o}{%
 \ifnum \value{elzc@Fichas} = 0%
  \PKGERROR{There are no index/flash cards in the stack}%
 \else
  \@elzc@fichastrue
  \if@elzc@fichaconreverso\@elzc@actualconreversotrue\else\@elzc@actualconreversofalse\fi
  \elzc@Predeterminados*
  \IfValueT{#2}{\setkeys{ELZc}{#2}}%
  \elzc@CicloCompleto
  \IfBooleanF{#1}{\elzc@TodoCero*}%
 \fi}
\let\MakeFC\MakeIC

\NewDocumentCommand{\BusinessCard}{+m +o}{%
 \ifx\undefined\@elzc@TarjetaAnverso
  \def\@elzc@TarjetaAnverso{#1}%
  \IfValueTF{#2}{%
   \@elzc@tarjetaconreversotrue
   \def\@elzc@TarjetaReverso{#2}%
   \immediate\write\@auxout{\string\@twosidetrue\string\@mparswitchtrue}}
  {\def\@elzc@TarjetaReverso{}}%
 \else
  \PackageError{elzcards}{There are business cards already defined}{}%
 \fi}

\NewDocumentCommand{\IndexCard}{+m +o}{%
 \addtocounter{elzc@Fichas}{1}%
 \expandafter\def\csname @elzc@FichaAnverso\romannumeral\value{elzc@Fichas}\endcsname{#1}%
 \IfValueTF{#2}{%
  \@elzc@fichaconreversotrue
  \expandafter\def\csname @elzc@FichaReverso\romannumeral\value{elzc@Fichas}\endcsname{#2}%
  \immediate\write\@auxout{\string\@twosidetrue\string\@mparswitchtrue}}
 {\expandafter\def\csname @elzc@FichaReverso\romannumeral\value{elzc@Fichas}\endcsname{}}}
\let\FlashCard\IndexCard

\NewDocumentCommand{\elzc@TodoCero}{s}{%
 \IfBooleanTF{#1}{%
  \setcounter{elzc@Fichas}{0}%
  \setcounter{elzc@FichasEnOrden}{0}%
  \@elzc@fichaconreversofalse}
 {\let\@elzc@TarjetaAnverso\undefined
  \let\@elzc@TarjetaReverso\undefined
  \@elzc@tarjetaconreversofalse}}

\NewDocumentCommand{\elzc@Predeterminados}{s}{%
 \elzc@DefAutoSep
 \elzc@DefMarcasCorte
 \let\elzc@ColorMarcas\elzc@DefColorMarcas
 \linethickness{\elzc@DefLinea}%
 \setlength{\elzc@SeparaX}{\elzc@DefSeparaX}%
 \setlength{\elzc@SeparaY}{\elzc@DefSeparaY}%
 \setlength{\elzc@TempLen}{\elzc@DefArista}\setcounter{elzc@Arista}{\elzc@TempLen}%
 \setlength{\elzc@TempLen}{\elzc@DefPunto}\setcounter{elzc@Punto}{\elzc@TempLen}%
 \IfBooleanTF{#1}
  {\elzc@DefTrasverso
   \setlength{\elzc@TarjXdim}{\elzc@DefFichaXdim}\setlength{\elzc@TarjYdim}{\elzc@DefFichaYdim}}%
  {\setlength{\elzc@TarjXdim}{\elzc@DefTPXdim}\setlength{\elzc@TarjYdim}{\elzc@DefTPYdim}}}

\newcommand*{\elzc@CalculaMatriz}{%
 \loop \ifnum\value{elzc@TempNumX} < \value{elzc@PapelX}%
 \advance\value{elzc@TempNumX} by \value{elzc@TarjXdim}{%
  \addtocounter{elzc@NumX}{1}%
  \addtocounter{elzc@TempNumX}{\value{elzc@SeparaX}}}%
 \repeat
 \loop \ifnum\value{elzc@TempNumY} < \value{elzc@PapelY}%
 \advance\value{elzc@TempNumY} by \value{elzc@TarjYdim}{%
  \addtocounter{elzc@NumY}{1}%
  \addtocounter{elzc@TempNumY}{\value{elzc@SeparaY}}}%
 \repeat
 \addtocounter{elzc@TempNumX}{-\value{elzc@SeparaX}}%
 \addtocounter{elzc@TempNumY}{-\value{elzc@SeparaY}}%
 \ifnum\value{elzc@TempNumX} > \value{elzc@PapelX}%
  \addtocounter{elzc@TempNumX}{-\value{elzc@TarjXdim}}%
  \addtocounter{elzc@NumX}{-1}%
 \fi
 \ifnum\value{elzc@TempNumY} > \value{elzc@PapelY}%
  \addtocounter{elzc@TempNumY}{-\value{elzc@TarjYdim}}%
  \addtocounter{elzc@NumY}{-1}%
 \fi
 \ifnum\value{elzc@NumX} = 0
  \PKGERROR{No space to print at least one card. Check dimensions}\stop
 \fi
 \ifnum\value{elzc@NumY} = 0
  \PKGERROR{No space to print at least one card. Check dimensions}\stop
 \fi}

\newcommand*{\elzc@ColumnasFilas}{%
 \ifnum\value{elzc@NumForzadoX} > \value{elzc@NumX}%
  \PKGWARNING{No space to print \arabic{elzc@NumForzadoX} columns;
   printing \arabic{elzc@NumX} columns instead}%
  \setcounter{elzc@NumForzadoX}{0}%
 \else
  \ifnum\value{elzc@NumForzadoX} > 0
   \addtocounter{elzc@TempNumX}{-\value{elzc@NumX} * \value{elzc@TarjXdim}
    + \value{elzc@NumForzadoX} * \value{elzc@TarjXdim}}%
   \setcounter{elzc@NumX}{\arabic{elzc@NumForzadoX}}%
  \fi
 \fi
 \ifnum\value{elzc@NumForzadoY} > \value{elzc@NumY}%
  \PKGWARNING{No space to print \arabic{elzc@NumForzadoY} rows;
   printing \arabic{elzc@NumY} rows instead}%
  \setcounter{elzc@NumForzadoY}{0}%
 \else
  \ifnum\value{elzc@NumForzadoY} > 0
   \addtocounter{elzc@TempNumY}{-\value{elzc@NumY} * \value{elzc@TarjYdim}
    + \value{elzc@NumForzadoY} * \value{elzc@TarjYdim}}%
   \setcounter{elzc@NumY}{\arabic{elzc@NumForzadoY}}%
  \fi
 \fi}

\newcommand*{\elzc@Cuadricula}{%
 \setlength{\elzc@TempUnitLength}{\unitlength}%
 \setlength{\unitlength}{1sp}%
 \setlength{\parindent}{0pt}%
 \thispagestyle{empty}%
 \elzc@Informacion
 \setcounter{elzc@MatrizXo}{
  (\value{elzc@PapelX} - \value{elzc@NumX} * (\value{elzc@TarjXdim} + \value{elzc@SeparaX})
  + \value{elzc@SeparaX}) / 2}%
 \setcounter{elzc@MatrizYo}
  {(\value{elzc@PapelY} - \value{elzc@NumY} * (\value{elzc@TarjYdim} + \value{elzc@SeparaY})
  + \value{elzc@SeparaY}) / 2}%
 \begin{picture}
  (\value{elzc@PapelX}, \value{elzc@PapelY})
  (-\value{elzc@MatrizXo}, -\value{elzc@MatrizYo})%
  \loop \ifnum\value{elzc@ContY} < \value{elzc@NumY}\advance\value{elzc@ContY} by 1{%
   \loop \ifnum\value{elzc@ContX} < \value{elzc@NumX}\advance\value{elzc@ContX} by 1{%
    \if@elzc@procesareverso
     \setcounter{elzc@PosX}{(\value{elzc@NumX} - \value{elzc@ContX} - 1) * \value{elzc@TarjXdim}
      + (\value{elzc@NumX} - \value{elzc@ContX} - 1) * \value{elzc@SeparaX}}%
    \else
     \setcounter{elzc@PosX}{\value{elzc@ContX} * (\value{elzc@TarjXdim} + \value{elzc@SeparaX})}%
    \fi
    \setcounter{elzc@PosY}{\value{elzc@PapelY} -
     (\value{elzc@ContY} * (\value{elzc@TarjYdim} + \value{elzc@SeparaY}))
     - \value{elzc@TarjYdim} - 2 * \value{elzc@MatrizYo}}%
    \ifnum \value{elzc@ContX} < \value{elzc@NumX}%
     \ifnum \value{elzc@ContY} < \value{elzc@NumY}%
      \put(\value{elzc@PosX}, \value{elzc@PosY}){%
       \makebox(\value{elzc@TarjXdim}, \value{elzc@TarjYdim}){%
        \setlength{\unitlength}{\elzc@TempUnitLength}%
        \parbox[t][\elzc@TarjYdim]{\elzc@TarjXdim}{%
         \if@elzc@fichas
          \ifnum\value{elzc@FichaActual} < \value{elzc@FichasEnOrden}%
           \addtocounter{elzc@FichaActual}{1}%
           \if@elzc@calculaorden
            \elzc@CalculaOrden
           \else
            \setcounter{elzc@FichaActualOrdenada}{\value{elzc@FichaActual}}%
           \fi
           \if@elzc@procesareverso
            \expandafter
             \csname @elzc@FichaReverso\romannumeral\value{elzc@FichaActualOrdenada}\endcsname
           \else
            \expandafter
             \csname @elzc@FichaAnverso\romannumeral\value{elzc@FichaActualOrdenada}\endcsname
           \fi
          \fi
         \else
          \if@elzc@procesareverso\@elzc@TarjetaReverso\else\@elzc@TarjetaAnverso\fi
         \fi}}}%
     \fi
    \fi
    \if@elzc@procesareverso\else\elzc@CalculaMarcas\fi
   }\repeat
  }\repeat
 \end{picture}\global\@elzc@iniciofalse}

\newcommand*{\elzc@Inicializa}{%
 \setcounter{elzc@NumX}{0}%
 \setcounter{elzc@NumY}{0}%
 \setcounter{elzc@TempNumX}{0}%
 \setcounter{elzc@TempNumY}{0}%
 \if@elzc@inicio
  \setcounter{elzc@PapelX}{\textwidth}%
  \setcounter{elzc@PapelY}{\textheight}%
  \setcounter{elzc@TarjXdim}{\elzc@TarjXdim}%
  \setcounter{elzc@TarjYdim}{\elzc@TarjYdim}%
 \fi
 \if@elzc@autosep
  \setlength{\elzc@SeparaX}{0pt}\setlength{\elzc@SeparaY}{0pt}%
 \fi
 \setcounter{elzc@SeparaX}{\elzc@SeparaX}%
 \setcounter{elzc@SeparaY}{\elzc@SeparaY}%
 \elzc@CalculaMatriz
 \if@elzc@columnasfilas\elzc@ColumnasFilas\fi
 \if@elzc@autosep
  \if@elzc@autoseptotal
   \setcounter{elzc@SeparaX}{
    (\value{elzc@PapelX} - \value{elzc@TempNumX}) / (\value{elzc@NumX} + 1)}%
   \setcounter{elzc@SeparaY}{
    (\value{elzc@PapelY} - \value{elzc@TempNumY}) / (\value{elzc@NumY} + 1)}%
  \else
   \ifnum\value{elzc@NumX} > 1
    \setcounter{elzc@SeparaX}{
     (\value{elzc@PapelX} - \value{elzc@TempNumX}) / (\value{elzc@NumX} - 1)}%
   \fi
   \ifnum\value{elzc@NumY} > 1
    \setcounter{elzc@SeparaY}{
     (\value{elzc@PapelY} - \value{elzc@TempNumY}) / (\value{elzc@NumY} - 1)}%
   \fi
  \fi
  \setlength{\elzc@SeparaX}{\value{elzc@SeparaX}sp}%
  \setlength{\elzc@SeparaY}{\value{elzc@SeparaY}sp}%
 \fi
 \setcounter{elzc@NumXY}{\value{elzc@NumX} * \value{elzc@NumY}}%
 \if@elzc@orden
  \setcounter{elzc@FichasEnOrden}
   {\value{elzc@Fichas} / \value{elzc@ElementosOrden} * \value{elzc@ElementosOrden}}
  \ifnum\value{elzc@FichasEnOrden} < \value{elzc@Fichas}%
   \addtocounter{elzc@FichasEnOrden}{\value{elzc@ElementosOrden}}%
  \fi
 \else
  \setcounter{elzc@FichasEnOrden}{\value{elzc@Fichas} / \value{elzc@NumXY} * \value{elzc@NumXY}}%
  \ifnum\value{elzc@FichasEnOrden} < \value{elzc@Fichas}%
   \addtocounter{elzc@FichasEnOrden}{\value{elzc@NumXY}}%
  \fi
 \fi
 \setcounter{elzc@ContX}{-1}%
 \setcounter{elzc@ContY}{-1}%
 \if@elzc@inicio
  \if@elzc@ordentransverso
   \elzc@CalculaOrdenTrasverso
  \else
   \if@elzc@orden\elzc@VerificaOrden\fi
  \fi
 \fi}

\newcommand*{\elzc@CicloCompleto}{%
 \@elzc@iniciotrue
 \elzc@Inicializa
 \if@elzc@fichas
  \loop\ifnum\value{elzc@FichaActual} < \value{elzc@FichasEnOrden}%
  {\elzc@CicloPagina}\repeat
  \setcounter{elzc@FichaActual}{0}%
  \@elzc@ordenfalse
  \@elzc@ordentransversofalse
  \@elzc@calculaordenfalse
 \else
  \elzc@CicloPagina
 \fi
 \@elzc@columnasfilasfalse
 \setcounter{elzc@NumForzadoX}{0}%
 \setcounter{elzc@NumForzadoY}{0}%
 \clearpage}

\newcommand*{\elzc@CicloPagina}{%
 {\pagestyle{empty}\cleardoublepage}%
 \elzc@Cuadricula
 \if@elzc@actualconreverso
  \@elzc@procesareversotrue
  \if@elzc@fichas\addtocounter{elzc@FichaActual}{-\value{elzc@NumXY}}\fi
  \clearpage
  \elzc@Cuadricula
  \@elzc@procesareversofalse
 \fi}

\newcommand*{\elzc@CalculaOrdenTrasverso}{%
 \setcounter{elzc@OrdenCiclo}{0}%
 \setcounter{elzc@OrdenCicloDos}{0}%
 \if@elzc@fichas
  \def\elzc@Orden{ }%
  \setcounter{elzc@Temp}{\value{elzc@Fichas} / \value{elzc@NumXY}}%
  \setcounter{elzc@TempDos}{\value{elzc@Temp} * \value{elzc@NumXY}}%
  \ifnum\value{elzc@TempDos} = \value{elzc@Fichas}%
  \else
   \addtocounter{elzc@Temp}{1}%
  \fi
  \loop \ifnum\value{elzc@OrdenCiclo} < \value{elzc@Temp}%
  \advance \value{elzc@OrdenCiclo} by 1{%
   \setcounter{elzc@TempDos}{\value{elzc@OrdenCiclo}}%
   \addtocounter{elzc@TempDos}{-\value{elzc@Temp}}%
   \loop \ifnum\value{elzc@OrdenCicloDos} < \value{elzc@NumXY}%
   \advance \value{elzc@OrdenCicloDos} by 1{%
    \addtocounter{elzc@TempDos}{\value{elzc@Temp}}%
    \global\edef\elzc@Orden{\elzc@Orden \arabic{elzc@TempDos} }%
   }\repeat
  }\repeat
  \elzc@aux@elementosorden
 \else
  \PKGWARNING{Transverse ordering not available on business cards}%
  \global\@elzc@ordentransversofalse
  \global\@elzc@calculaordenfalse
 \fi}

\newcommand*{\elzc@ErrorEnPatronOrden}{%
 \PKGWARNING{Ordering pattern incorrectly given. Ignoring it}%
 \global\@elzc@ordenfalse
 \global\@elzc@calculaordenfalse}

\newcommand*{\elzc@VerificaOrden}{%
 \if@elzc@fichas
  \setcounter{elzc@Temp}{\value{elzc@ElementosOrden} - \value{elzc@ElementosOrden} /
   \value{elzc@NumXY} * \value{elzc@NumXY}}%
  \ifnum\value{elzc@Temp} = 0
  \else
   \ifnum\value{elzc@Temp} = \value{elzc@Fichas}%
    \else
     \ifnum\value{elzc@ElementosOrden} = \value{elzc@Fichas}%
     \else
      \elzc@ErrorEnPatronOrden
     \fi
    \fi
  \fi
  \if@elzc@orden
   \setcounter{elzc@OrdenCiclo}{0}%
   \loop \ifnum\value{elzc@OrdenCiclo} < \value{elzc@ElementosOrden}%
   \advance \value{elzc@OrdenCiclo} by 1{%
    \setcounter{elzc@OrdenCicloDos}{0}%
    \loop \ifnum\value{elzc@OrdenCicloDos} < \value{elzc@ElementosOrden}%
    \advance \value{elzc@OrdenCicloDos} by 1{%
     \elzc@aux@fichatransversa{\value{elzc@OrdenCicloDos}}{elzc@Temp}%
     \ifnum\value{elzc@OrdenCiclo} = \value{elzc@Temp}%
      \setcounter{elzc@OrdenCicloDos}{\value{elzc@ElementosOrden}}%
     \else
      \ifnum\value{elzc@OrdenCicloDos} = \value{elzc@ElementosOrden}%
       \elzc@ErrorEnPatronOrden
       \setcounter{elzc@OrdenCiclo}{\value{elzc@ElementosOrden}}%
      \fi
     \fi
    }\repeat
   }\repeat
  \fi
 \else
  \PKGWARNING{Ordering pattern not available on business cards}%
  \global\@elzc@ordenfalse
  \global\@elzc@calculaordenfalse
 \fi}

\newcommand*{\elzc@CalculaOrden}{%
 \setcounter{elzc@OrdenCiclo}{\value{elzc@FichaActual} / \value{elzc@ElementosOrden}}%
 \setcounter{elzc@OrdenResto}{\value{elzc@FichaActual} - \value{elzc@FichaActual} /
  \value{elzc@ElementosOrden} * \value{elzc@ElementosOrden}}%
 \ifnum\value{elzc@OrdenResto} = 0
  \addtocounter{elzc@OrdenCiclo}{-1}%
  \setcounter{elzc@OrdenResto}{\value{elzc@ElementosOrden}}%
 \fi
 \elzc@aux@fichatransversa{\value{elzc@OrdenResto}}{elzc@FichaActualOrdenada}%
 \addtocounter{elzc@FichaActualOrdenada}{\value{elzc@OrdenCiclo} * \value{elzc@ElementosOrden}}}

\newcommand*{\elzc@CalculaMarcas}{%
 \setcounter{elzc@PosMarcaX}{\value{elzc@PosX}}%
 \setcounter{elzc@PosMarcaY}{\value{elzc@PosY} + \value{elzc@TarjYdim}}%
 \ifnum \value{elzc@ContX} = \value{elzc@NumX}%
 \else
  \ifnum \value{elzc@ContY} = \value{elzc@NumY}%
  \else
   \elzc@DibujaMarcas{\value{elzc@PosMarcaX}}{\value{elzc@PosMarcaY}}%
  \fi
 \fi
 \addtocounter{elzc@PosMarcaX}{-\value{elzc@SeparaX}}%
 \ifnum \value{elzc@ContX} = 0
 \else
  \ifnum \value{elzc@ContY} = \value{elzc@NumY}%
  \else
   \elzc@DibujaMarcas{\value{elzc@PosMarcaX}}{\value{elzc@PosMarcaY}}%
  \fi
 \fi
 \addtocounter{elzc@PosMarcaY}{\value{elzc@SeparaY}}%
 \ifnum \value{elzc@ContX} = 0
 \else
  \ifnum \value{elzc@ContY} = 0
  \else
   \elzc@DibujaMarcas{\value{elzc@PosMarcaX}}{\value{elzc@PosMarcaY}}%
  \fi
 \fi
 \addtocounter{elzc@PosMarcaX}{\value{elzc@SeparaX}}%
 \ifnum \value{elzc@ContY} = 0
 \else
  \ifnum \value{elzc@ContX} = \value{elzc@NumX}%
  \else
   \elzc@DibujaMarcas{\value{elzc@PosMarcaX}}{\value{elzc@PosMarcaY}}%
  \fi
 \fi}

\newcommand*{\elzc@DibujaMarcas}[2]{%
 \ifnum \value{elzc@ContX} = 0
  \if@elzc@segmentos\put(#1,#2){\color{\elzc@ColorMarcas}\line(-1,0){\value{elzc@Arista}}}\fi
  \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
 \else
  \ifnum \value{elzc@ContX} = \value{elzc@NumX}%
   \if@elzc@segmentos\put(#1,#2){\color{\elzc@ColorMarcas}\line(2,0){\value{elzc@Arista}}}\fi
   \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
  \else
   \if@elzc@cruces
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(-1,0){\value{elzc@Arista}}}%
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(2,0){\value{elzc@Arista}}}%
   \fi
   \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
   \if@elzc@lineas
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(-1,0){\value{elzc@TarjXdim}}}%
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(2,0){\value{elzc@TarjXdim}}}%
   \fi
  \fi
 \fi
 \ifnum \value{elzc@ContY} = 0
  \if@elzc@segmentos\put(#1,#2){\color{\elzc@ColorMarcas}\line(0,0){\value{elzc@Arista}}}\fi
  \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
 \else
  \ifnum \value{elzc@ContY} = \value{elzc@NumY}%
   \if@elzc@segmentos\put(#1,#2){\color{\elzc@ColorMarcas}\line(0,-1){\value{elzc@Arista}}}\fi
   \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
  \else
   \if@elzc@cruces
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(0,0){\value{elzc@Arista}}}%
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(0,-1){\value{elzc@Arista}}}%
   \fi
   \if@elzc@puntos\put(#1,#2){\color{\elzc@ColorMarcas}\circle*{\value{elzc@Punto}}}\fi
   \if@elzc@lineas
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(0,0){\value{elzc@TarjYdim}}}%
    \put(#1,#2){\color{\elzc@ColorMarcas}\line(0,-1){\value{elzc@TarjYdim}}}%
   \fi
  \fi
 \fi}

\newcommand*{\elzc@Informacion}{%
 \message{^^JProcessing}%
 \if@elzc@fichas\message{index/flash cards,}\else\message{business cards,}\fi
 \if@elzc@procesareverso
  \message{back side,^^J}%
 \else
  \if@elzc@actualconreverso\else\message{only}\fi
  \message{front side,^^J}%
 \fi
 \if@elzc@fichas
  \setcounter{elzc@Temp}{\value{elzc@NumXY} + \value{elzc@FichaActual}}%
  \addtocounter{elzc@FichaActual}{1}%
  \message{ current=\arabic{elzc@FichaActual}-\arabic{elzc@Temp}}%
  \message{of \arabic{elzc@FichasEnOrden},}%
  \message{total cards=\arabic{elzc@Fichas},}%
  \if@elzc@calculaorden
   \if@elzc@ordentransverso \message{transverse order,}\fi
   \if@elzc@orden \message{reordered,}\fi
  \fi
  \addtocounter{elzc@FichaActual}{-1}%
  \message{^^J}%
 \fi
 \message{ per page:
  \ifnum\value{elzc@NumForzadoX} > 0
   forced
  \else
   \ifnum\value{elzc@NumForzadoY} > 0
    forced
   \fi
  \fi
  \arabic{elzc@NumXY} (\arabic{elzc@NumX}x\arabic{elzc@NumY}),}%
 \message{hsize=\the\elzc@TarjXdim, vsize=\the\elzc@TarjYdim,^^J}%
 \message{ hgap=\the\elzc@SeparaX, vgap=\the\elzc@SeparaY,
  \if@elzc@autosep
   \if@elzc@autosepinterno auto gap inner,\fi
   \if@elzc@autoseptotal auto gap total,\fi
  \else no auto gap,
  \fi^^J}%
 \if@elzc@cruces
  \message{ with crosses,}%
  \setlength{\elzc@TempLen}{\value{elzc@Arista}sp}%
  \message{segment length=\the\elzc@TempLen, line thickness=\the\@wholewidth.^^J}%
 \else
  \if@elzc@segmentos
   \message{ with segments,}%
   \setlength{\elzc@TempLen}{\value{elzc@Arista}sp}%
   \message{segment length=\the\elzc@TempLen, line thickness=\the\@wholewidth.^^J}%
  \fi
 \fi
 \if@elzc@puntos
  \message{ with dots,}%
  \setlength{\elzc@TempLen}{\value{elzc@Punto}sp}%
  \message{dot size=\the\elzc@TempLen.^^J}%
 \fi
 \if@elzc@lineas
  \message{ with lines, line thickness=\the\@wholewidth.^^J}%
 \fi
 \if@elzc@sinmarcas
  \message{ without cropping marks.^^J}%
 \fi}

\setlength{\elzc@DefTPXdim}{3.5in}
\setlength{\elzc@DefTPYdim}{2in}
\setlength{\elzc@DefFichaXdim}{5in}
\setlength{\elzc@DefFichaYdim}{3in}
\setlength{\elzc@DefSeparaX}{0cm}
\setlength{\elzc@DefSeparaY}{0cm}
\setlength{\elzc@DefArista}{1mm}
\setlength{\elzc@DefPunto}{1pt}
\setlength{\elzc@DefLinea}{0.1mm}
\CropColor{red!90!black}
\CropCrosses
\NoAutoGap
\NoTransverse

\InputIfFileExists{\jobname.aux}{}\relax

\endinput
%%
%% End of file `elzcards.sty'.
