Tengo que crear recibos de escritorio (etiquetas). Para estos datos está disponible en hoja de Excel. Los nombres de las columnas son: RollNo, Asunto, Lugar del examen (centro de examen).
Actualmente estamos creando notas de escritorio usando CSVtools
. La etiqueta parece...
NAME OF EXAMINATION
Subject : xyz
Roll No. : 000000
Para ello, tenemos que crear varias hojas de datos csv: lugar del examen y materia. ¿Hay alguna manera de que, sin crear varias hojas de datos csv, podamos crear etiquetas según el lugar y el tema del examen?
MWE:
\documentclass[a4paper,12pt]{article}
\usepackage{csvtools}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
RollNo,Subject,Venue
022701,Sociology,Deptt. of Physics
022702,Sociology,Deptt. of Physics
022704,Sociology,Deptt. of Physics
022705,Sociology,Deptt. of Physics
022706,Sociology,Deptt. of Physics
022707,Sociology,Deptt. of Physics
022708,Sociology,Deptt. of Physics
022709,Sociology,Deptt. of Physics
022709,Sociology,Deptt. of Physics
022710,Sociology,Deptt. of Physics
023001,Psychology,Deptt. of Physics
023002,Psychology,Deptt. of Physics
023004,Psychology,Deptt. of Physics
023005,Psychology,Deptt. of Physics
023006,Psychology,Deptt. of Physics
023007,Psychology,Deptt. of Physics
023008,Psychology,Deptt. of Physics
023009,Psychology,Deptt. of Physics
023010,Psychology,Deptt. of Physics
\end{filecontents*}
\begin{document}
\applyCSVfile{data.csv}{% here put the name of the file
%\begin{multicols}{2}
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \insertSubject}\\[5pt]
{\Large Roll No. : \textbf{0\insertRollNo}}\\[12pt]
}} % This is for parbox
%\end{multicols}
}% This is for CSV file
\end{document}
Respuesta1
Aquí hay un código que debería servir como punto de partida. Esto usa datatool
el paquete. He agregado una columna con una clave corta center
además de sus columnas.
center,RollNo,Subject,Venue
Bangalore,022701,Sociology,Deptt. of Physics
Bangalore,022702,Sociology,Deptt. of Physics
Bangalore,022704,Sociology,Deptt. of Physics
Bangalore,022705,Sociology,Deptt. of Physics
En la cuarta columna, puede especificar el centro completo si lo desea.
\documentclass[a4paper,12pt]{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{xcolor}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
center,RollNo,Subject,Venue
Bangalore,022701,Sociology,Deptt. of Physics
Bangalore,022702,Sociology,Deptt. of Physics
Bangalore,022704,Sociology,Deptt. of Physics
Bangalore,022705,Sociology,Deptt. of Physics
Bangalore,022706,Sociology,Deptt. of Physics
Bangalore,022707,Sociology,Deptt. of Physics
Bangalore,022708,Sociology,Deptt. of Physics
Bangalore,022709,Sociology,Deptt. of Physics
Bangalore,022709,Sociology,Deptt. of Physics
Bangalore,022710,Sociology,Deptt. of Physics
Mangalore,023001,Psychology,Deptt. of Physics
Mangalore,023002,Psychology,Deptt. of Physics
Mangalore,023004,Psychology,Deptt. of Physics
Mangalore,023005,Psychology,Deptt. of Physics
Mangalore,023006,Psychology,Deptt. of Physics
Mangalore,023007,Psychology,Deptt. of Physics
Mangalore,023008,Psychology,Deptt. of Physics
Mangalore,023009,Psychology,Deptt. of Physics
Mangalore,023010,Psychology,Deptt. of Physics
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb{data}{data.csv}
\begin{document}
This is for Bangalore center
\DTLforeach*[\DTLisopenbetween{\center}{B}{C}]{data}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\clearpage
This is for Mangalore
\DTLforeach*[\DTLisopenbetween{\center}{M}{N}]{data}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\clearpage
This is for Sociology
\DTLforeach*[\DTLisopenbetween{\sub}{S}{T}]{data}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\clearpage
This is for Psychology
\DTLforeach*[\DTLisopenbetween{\sub}{P}{Q}]{data}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\end{document}
Tenga en cuenta que para archivos csv grandes, esto puede compilarse lentamente. Esto se puede curar hasta cierto punto usando pgfplotstable
. Aquí se puede filtrar un archivo de datos único y grande para un centro o tema en particular y se pueden crear archivos csv individuales sobre la marcha. Una vez creados, puede crear las etiquetas usando su csvtools
forma de paquete o usando datatool
. Aquí está el código de muestra que usa lo mismo data.csv
que en el código anterior.
\documentclass[a4paper,12pt]{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{xcolor}
\usepackage{pgfplotstable,xstring}
\pgfplotsset{compat=1.11}
\usepackage{datatool}
\pgfplotstableread[col sep=comma]{data.csv}\data
\begin{document}
%%----------------------------------------------------------subjectwise
%% following will filter all Psychology rows and save it as Psychology.csv
\pgfplotstablesave[col sep=comma,
row predicate/.code={%
\pgfplotstablegetelem{#1}{Subject}\of\data%
\IfStrEq{\pgfplotsretval}{Psychology}{%True %% >>imp<< Psychology is case sensitive, psychology won't work
\relax}%
{\pgfplotstableuserowfalse}%False
}%
]
{\data}
{Psychology.csv}
%%----------------------------------------------------------
%% from here use datatool
\DTLloaddb{Psychology}{Psychology.csv}
\DTLforeach{Psychology}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\clearpage
%%---------------------------------------------------------- centerwise
%% following will filter all Bangalore rows and save it as bangalore.csv
\pgfplotstablesave[col sep=comma,
row predicate/.code={%
\pgfplotstablegetelem{#1}{center}\of\data%
\IfStrEq{\pgfplotsretval}{Bangalore}{%True %% >>imp<< Bangalore is case sensitive
\relax}%
{\pgfplotstableuserowfalse}%False
}%
]
{\data}
{bangalore.csv}
%%----------------------------------------------------------
%% from here use datatool/csvtools
\DTLloaddb{bangalore}{bangalore.csv}
\DTLforeach{bangalore}{%
\center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\end{document}