How to create a custom list and \item element?
You can quite easily define your own lists. Put that in an environment, define a custom item. Here you go (you don't need the geometry
package, I just hate to waste too much space):
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\newcounter{itemnumber}
\newenvironment{mylist}[1]{% Prefix
\setcounter{itemnumber}{0}%
\begin{list}{\textbf{#1}}{}%
}{\end{list}}
\newcommand{\myentry}[2]{% Number, Text
\stepcounter{itemnumber}%
\item \textit{#1}: \theitemnumber\ #2%
}
\begin{document}
\begin{mylist}{myPrefix}
\myentry{2}{lorem ipsum adin}
\myentry{7}{lorem ipsum dwa}
\myentry{6}{lorem ipsum tri}
\end{mylist}
\end{document}
Edit 1: For referencable entries you can use hyperref
s hyperlink
and hypertarget
:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{lipsum}
\usepackage[colorlinks]{hyperref}
\newcounter{itemnumber}
\newenvironment{mylist}[1]{% Prefix
\setcounter{itemnumber}{0}%
\begin{list}{\textbf{#1}}{}%
}{\end{list}}
\newcommand{\myentry}[2]{% Number, Text
\stepcounter{itemnumber}%
\item \textit{#1}: \theitemnumber\ #2%
}
\newcommand{\mylinkentry}[3]{% Number, Text, linklabel
\stepcounter{itemnumber}%
\item \textit{#1}: \theitemnumber\ \hypertarget{#3}{#2}%
}
\begin{document}
\hrule
\begin{mylist}{myPrefix}
\myentry{2}{lorem ipsum adin}
\myentry{7}{lorem ipsum dwa}
\myentry{6}{lorem ipsum tri}
\end{mylist}
\hrule
\begin{mylist}{some numbers}
\mylinkentry{13}{bad luck}{item.one}
\mylinkentry{665}{neighbour of the beast}{item.two}
\mylinkentry{1337}{deep magic wizard}{item.three}
\end{mylist}
\hrule
Many people believe number \hyperlink{item.one}{13} to be bad luck.\\
The code was still blinking on th screen: \hyperlink{item.two}{665...}\\
Some people just got \hyperlink{item.three}{a lot more skill} than others.
\end{document}
One way is to let enumitem do some job
\documentclass[a4paper]{article}
\usepackage{enumitem}
\newlist{mylist}{enumerate}{1}
\setlist[mylist]{label*=RQ\arabic*:~,ref=RQ\arabic*}
\makeatletter
\newcommand\myitem[1][]{%
\if\relax\detokenize{#1}\relax
\item\relax
\else
\protected@edef\@currentlabel{RQ#1}%
\item[RQ#1:~]
\fi}
\makeatother
\begin{document}
\begin{mylist}
\myitem\label{x} x
\myitem[3]\label{y} y
\myitem z
\end{mylist}
--\ref{x}--\ref{y}--
\end{document}
The complicated conditional is just to make correct references also for \myitem[x]
. Some other code can be added for getting also hyperlinks.
Check enumitem's documentation for how to change the other list parameters (indentation, label width and so on).
Addition
To get the numbering scheme you're proposing, change the code into
\usepackage{enumitem}
\newlist{mylist*}{enumerate}{1}
\setlist[mylist*]{label=\mylistprefix-\mylistopt-\arabic*:~,
ref=\mylistprefix-\mylistopt-\arabic*}
\makeatletter
\let\mylistopt\relax % to keep enumitem happy
\newcommand\myitem[1][]{%
\if\relax\detokenize{#1}\relax
\def\mylistopt{0}% no optional argument to \myitem
\else
\def\mylistopt{#1}% optional argument to \myitem
\fi
\item\relax}
\makeatother
\newenvironment{mylist}[1][myPrefix]
{\def\mylistprefix{#1}\begin{mylist*}}
{\end{mylist*}}
You call it as
\begin{mylist}
\myitem[2] \label{a} lorum ipsum lorum ipsum
\myitem[7] lorum ipsum etc.
\myitem[6] \label{b} lorum ipsum etc.
\myitem ll
\end{mylist}
or
\begin{mylist}[RQ]
\myitem[2] \label{a} lorum ipsum lorum ipsum
\myitem[7] lorum ipsum etc.
\myitem[6] \label{b} lorum ipsum etc.
\myitem ll
\end{mylist}
to get RQ
as the prefix.
A different implementation
Suppose you want the numbering of items to be unique for the whole document, but that you also want to decide at some point from where to start numbering. A key-value interface is more suitable:
\documentclass[a4paper]{article}
\usepackage{enumitem,keyval}
\makeatletter
\define@key{vort3xlist}{prefix}{\def\mylistprefix{#1}}
\define@key{vort3xlist}{start}{\setcounter{mylistcnt}{#1}}
\makeatother
\newcounter{mylistcnt}
\newlist{mylist*}{enumerate}{1}
\setlist[mylist*]{label=\mylistprefix-\mylistopt-\arabic{mylistcnt}:~,
ref=\mylistprefix-\mylistopt-\arabic{mylistcnt}}
\makeatletter
\let\mylistopt\relax
\newcommand\myitem[1][]{%
\refstepcounter{mylistcnt}%
\if\relax\detokenize{#1}\relax
\def\mylistopt{0}%
\else
\def\mylistopt{#1}%
\fi
\item\relax}
\makeatother
\newenvironment{mylist}[1][]
{\setkeys{vort3xlist}{prefix=RQ}%change here your default prefix
\setkeys{vort3xlist}{#1}%
\begin{mylist*}}
{\end{mylist*}}
\begin{document}
Look at \ref{a}, and \ref{b}
\begin{mylist}[start=3,prefix=XYZ]
\myitem[2] \label{a} lorum ipsum lorum ipsum
\myitem[7] lorum ipsum etc.
\myitem[6] \label{b} lorum ipsum etc.
\myitem \label{x} ll
\end{mylist}
Here's a second list
\begin{mylist}
\myitem[2] \label{c} lorum ipsum lorum ipsum
\myitem[7] lorum ipsum etc.
\myitem[6] \label{d} lorum ipsum etc.
\myitem \label{y} ll
\end{mylist}
\ref{c}, \ref{d}
\ref{x} and \ref{y}
\end{document}
The keys accepted are prefix
and start
, as you can see in the first mylist
.