Traceability Matrix
up vote
2
down vote
favorite
My aim is to build an automatic Traceability Matrix at the end of my document. For that, I define all requirements to be validated at first and after, in different sections which one is tested.
The code is based on this issue, but I'd like to simplify this with an automatic generation of label name, and for that, I want to use a counter.
This is the code:
documentclass{article}
newcommand{requirements}{}
providecommand*phantomsection{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}gdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
Like you can see in the picture the generation with the counter function doesn't work. The Matrix doesn't link the correct test to the good requirement.
cross-referencing xint
add a comment |
up vote
2
down vote
favorite
My aim is to build an automatic Traceability Matrix at the end of my document. For that, I define all requirements to be validated at first and after, in different sections which one is tested.
The code is based on this issue, but I'd like to simplify this with an automatic generation of label name, and for that, I want to use a counter.
This is the code:
documentclass{article}
newcommand{requirements}{}
providecommand*phantomsection{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}gdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
Like you can see in the picture the generation with the counter function doesn't work. The Matrix doesn't link the correct test to the good requirement.
cross-referencing xint
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
My aim is to build an automatic Traceability Matrix at the end of my document. For that, I define all requirements to be validated at first and after, in different sections which one is tested.
The code is based on this issue, but I'd like to simplify this with an automatic generation of label name, and for that, I want to use a counter.
This is the code:
documentclass{article}
newcommand{requirements}{}
providecommand*phantomsection{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}gdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
Like you can see in the picture the generation with the counter function doesn't work. The Matrix doesn't link the correct test to the good requirement.
cross-referencing xint
My aim is to build an automatic Traceability Matrix at the end of my document. For that, I define all requirements to be validated at first and after, in different sections which one is tested.
The code is based on this issue, but I'd like to simplify this with an automatic generation of label name, and for that, I want to use a counter.
This is the code:
documentclass{article}
newcommand{requirements}{}
providecommand*phantomsection{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}gdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
Like you can see in the picture the generation with the counter function doesn't work. The Matrix doesn't link the correct test to the good requirement.
cross-referencing xint
cross-referencing xint
edited 2 days ago
Andrew
29.3k34178
29.3k34178
asked Jan 5 at 11:34
Darkilious
132
132
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
newcommand{spec}[1]{label{spec@#1}def@currentspec{spec@#1}}
will use the argument #1
, in this case theargcount
. This is evaluated too late here, you need the value (or expansion) of theargcount
in the very moment spec
is applied, i.e. use xdef@currentspec{spec@#1}
.
documentclass{article}
newcommand{requirements}{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}xdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
clearpage
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
newcommand{spec}[1]{label{spec@#1}def@currentspec{spec@#1}}
will use the argument #1
, in this case theargcount
. This is evaluated too late here, you need the value (or expansion) of theargcount
in the very moment spec
is applied, i.e. use xdef@currentspec{spec@#1}
.
documentclass{article}
newcommand{requirements}{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}xdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
clearpage
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
add a comment |
up vote
2
down vote
accepted
newcommand{spec}[1]{label{spec@#1}def@currentspec{spec@#1}}
will use the argument #1
, in this case theargcount
. This is evaluated too late here, you need the value (or expansion) of theargcount
in the very moment spec
is applied, i.e. use xdef@currentspec{spec@#1}
.
documentclass{article}
newcommand{requirements}{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}xdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
clearpage
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
newcommand{spec}[1]{label{spec@#1}def@currentspec{spec@#1}}
will use the argument #1
, in this case theargcount
. This is evaluated too late here, you need the value (or expansion) of theargcount
in the very moment spec
is applied, i.e. use xdef@currentspec{spec@#1}
.
documentclass{article}
newcommand{requirements}{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}xdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
clearpage
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
newcommand{spec}[1]{label{spec@#1}def@currentspec{spec@#1}}
will use the argument #1
, in this case theargcount
. This is evaluated too late here, you need the value (or expansion) of theargcount
in the very moment spec
is applied, i.e. use xdef@currentspec{spec@#1}
.
documentclass{article}
newcommand{requirements}{}
makeatletter
newcommand{req}[1]{%
textbf{R#1}%
phantomsection
def@currentlabel{R#1}%
label{req@#1}%
g@addto@macrorequirements{{req@#1}}%
global@namedef{req@#1@ismetby}{}%
}
newcommand{meetsreq}[1]{%
ref{req@#1}%
expandafterg@addto@macrocsname req@#1@ismetbyexpandafterendcsname
expandafter {expandafter{@currentspec}}%
}
newcommand{specswithreq}[1]%
% The space before ref below is intentional and will be swallowed by xintApply
% It is not mandatory however, the thing works without it too.
{xintListWithSep{, }{xintApply { ref}{csname #1@ismetbyendcsname }}}
newcommand{spec}[1]{label{spec@#1}xdef@currentspec{spec@#1}}
% (update Jan 5, to use gdef rather than def in spec, allowing more flexible usage; has its pros and cons)
makeatother
usepackage{xinttools}
usepackage{hyperref}% check if ok with hyperlinks
hypersetup{colorlinks=true}
newcounter{argcnt}setcounter{argcnt}{0}
begin{document}
section{Requirement LIST}
[req{R1}] requirement 1
[req{R2}] requirement 2
[req{R3}] requirement 3
[req{R4}] requirement 4
[req{R5}] requirement 5
[req{R6}] requirement 6
section{section1}
setcounter{argcnt}{1}
spec{1} Test 1 covert : meetsreq{R1} meetsreq{R2}
section{section2}
setcounter{argcnt}{2}
spec{theargcnt} Test 2 covert : meetsreq{R4} meetsreq{R2}
section{section3}
setcounter{argcnt}{3}
spec{3} Test 3 covert : meetsreq{R6}
section{section4}
setcounter{argcnt}{4}
spec{4} Test 4 covert : meetsreq{R2}, meetsreq{R3}
clearpage
section{Tracability MAtrix}
begin{table}[htbp]
begin{tabular}{|l|l|}
hline
Requirement & Specification \
hline
xintFor* #1 in requirementsdo {ref{#1}&specswithreq{#1}\
hline }%
end{tabular}
end{table}
end{document}
answered Jan 5 at 12:27
Christian Hupfer
146k14186377
146k14186377
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f408935%2ftraceability-matrix%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown