我必须创建桌单(标签)。此数据可在 Excel 表中找到。列名称为 - RollNo、科目、考试地点(考试中心)。
目前我们正在使用 创建桌单CSVtools
。标签如下所示 -
NAME OF EXAMINATION
Subject : xyz
Roll No. : 000000
为此,我们必须创建多个 csv 数据表 - 考试地点和科目。有没有一种方法,无需创建多个 csv 数据表,我们就可以创建考试地点和科目的标签?
梅威瑟:
\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}
答案1
以下是一些可以作为起点的代码。这使用包。除了您的列之外,datatool
我还添加了一个带有短键的列。center
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
在第四列中,您可以根据需要指定完整的中心。
\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}
请注意,对于大型 csv 文件,编译速度可能会很慢。使用 可以在一定程度上解决这个问题。在这里,可以为特定中心或主题过滤出大型的单个数据文件,并且可以动态创建单独的 csv 文件。创建这些文件后,您可以使用包方式或使用pgfplotstable
创建标签。以下是使用与上一个代码相同的示例代码。csvtools
datatool
data.csv
\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}