I want to do the following thing in Latex:
I have a custom environment like this:
\documentclass{article}
\usepackage{hyperref}
\usepackage{tabularx}
\title{Item Table Test}
\newcounter{ItemDescriptionCnt}
\makeatletter
\renewcommand{\theItemDescriptionCnt}{Item \@arabic\c@ItemDescriptionCnt}
\makeatother
\newenvironment{ItemDescription}[5][]{\refstepcounter{ItemDescriptionCnt}\par\medskip
\begin{tabularx}{\textwidth}{|>{\hsize=.2\hsize}X|>{\hsize=.6\hsize}X|>{\hsize=.2\hsize}X|}
\hline
\textbf{Item No.} & \textbf{Titel} & \textbf{Type} \\
\theItemDescriptionCnt & #2 & Item \\
\hline
\multicolumn{3}{|l|}{\textbf{Description:}} \\
\multicolumn{3}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth}|}{#3} \\
\hline
\multicolumn{2}{|l|}{\textbf{Note:} } & \textbf{Status:} \\
\multicolumn{2}{|>{\hsize=.8\hsize}X|}{#4} & #5 \\
\hline
\end{tabularx}
\noindent \rmfamily}{\medskip}
\newcommand{\itemdescription}[5]{
\begin{ItemDescription}{#1}{#2}{#3}{#4}
#5
\end{ItemDescription}
}
\begin{document}
\itemdescription{This is the title}{This is the description.}{This is the note.}{pending}{\label{e}}
Here I reference \ref{e}.
\end{document}
This means I can then do
\itemdescription{This is the title}{This is the description.}{This is the note.}{pending}{\label{e}}
Here I reference \ref{e}.
Here you can see the generated file:

Which I already like! Now I would like to customize the reference.
I would like to do:
This is long reference: \longref{e}
Which should result in:
This is long reference: Item 1 - This is the title (pending)
I sadly can not figure this out -.- I hope someone knows how to do that. Thanks in advance!
Bant
I figured it out. In case somebody want to do something similar I want to add how I got it doing what I want it to do.
The key is to use:
inside
If I understand this correctly (And please correct me if I am wrong), the
\expandafterlets the arguments first be "expanded" before the the\defis run. The\csname [...] \endcsnamelets you define a constructed command within the enclosure. Then themyitem\theItemDescriptionCntconstructs a command, which in my example looks like this:myitemItem 1, which, when run, refers to the argument {#1}.The following command
\longrefthen does pretty much exactly the same. It uses the input to get the reference number. It then puts it together to get the same command (inside the\csnameenclosure), which was generated before. The command then outputts the argument given before:My complete example looks like this:
This generates: