A database in a format that can be freely defined had entities with the following attributes:
ID, HEXNUMBER, LATEXFORMULA, LITERAL.
The ID is unique and can contain numbers, dots and dashed. Example:
MystructOne.val16_AHEXNUMBER is always an address like
0xD0007246.LATEXFORMULA will look like so:
$p = \frac{57426}{10^8} \mathrm{[V]} \cdot i$The LITERAL will contain type information:
UINT(t16)
I am free to save the data however I want, but the contents is fixed. How can I save them so that I can access them in LaTeX with something like the following:
\custom{MystructOne.val16_A}{ID}
\custom{MystructOne.val16_A}{HEXNUMBER}
\custom{MystructOne.val16_A}{LATEXFORMULA}
\custom{MystructOne.val16_A}{LITERAL}
and at one point I would like to generate a table using something like the following:
foreach key in keysource
{
\custom{key}{ID}
\custom{key}{HEXNUMBER}
\custom{key}{LATEXFORMULA}
\custom{key}{LITERAL}
}
What can I do in LaTeX to access data like that?
EDIT #2 (replaced previous edit)
This is how far i have gotten now:
\documentclass{article}
\usepackage{hyperref}
\newcounter{keylabel}
\newcommand*{\keylabel}[2]{%
\leavevmode%
\raisebox{2ex}[0pt][0pt]{%
\renewcommand*{\thekeylabel}{#1}%
\refstepcounter{keylabel}%
\label{#2}%
}%
#1%
}
\usepackage[T1]{fontenc}
\usepackage{csvtools}
\setcsvseparator{;}
\def\verbID{\texttt{\edef\tmp{\insertID}\expandafter\detokenize\expandafter{\tmp}}}
\newcommand{\DATARow}[4]{\keylabel{#1}{#1} & #2 & #3 & #4\\[.5ex]}
%The keylabel throws a lot of errors here
\begin{document}
%%% - Creating the Table
\CSVtotabular{stackoverflow.csv}%
{|c|c|c|c|}%
{\DATARow{ID}{REGISTER}{TYPE}{FORMULA}}%
{\DATARow{\verbID}{\insertREGISTER}{\insertTYPE}{\insertFORMULA}}%
{\DATARow{\verbID}{\insertREGISTER}{\insertTYPE}{\insertFORMULA}}
\newpage
%%% - Referencing something in the Table:
\noindent
%\ref{A_B_C_D}\\ - Does not work at all
%\ref{ONE}\\ - Does not work at all
%\ref{TWO.FOUR}\\ - Does not work at all
%\ref{Thirty[2]}\\ - Does not work at all
%\ref{TreeHouse}\\ - Does not work at all
\end{document}
The final step will be to be able to set Keylables and reference them. I want the referencing to work like in this answer here.
But i am getting errors and warnings.
- I can not set the keys, some envireonment collision i dont understand.
- I was not able to test this, but i think i need a \verbRef.
- I need to supress the warnings in texlipse that will occur since the keys can only be set during compile time. I dont know how to do that.
These final items are the ones in need to clear before i can reasonably say that i am looking up the values that i need.
Here is a demo csv file that can be used with this problem:
ID;REGISTER;TYPE;FORMULA
A_B_C_D;0xD000720C;UINT(16);$Y = \frac{57426}{10^8} \cdot X$
ONE;0xD020720C;UINT(8);$Y = 109 \cdot X$
TWO.FOUR;0xD080720C;INT(16);$Y = \frac{57426}{X}$
Thirty[2];0xD009720C;INT(8);$Y = X$
TreeHouse;0xD200720C;UINT(32);$Y = \frac{X}{10^8} \cdot X$


datatool, provided that you have the data available as CSV. – Werner Feb 22 '13 at 16:20