On 03/25/2012 04:15 PM, John Carbone wrote:

Much in the way that the tab key iterates over section levels:

Part ->  Chapter ->  Section ->  Subsection ->  Subsubsection ->  Paragraph ->  
Subparagraph

I would like to do the same thing for my requirements, see code below. For example, pressing a key or key sequence on keyboard "Requirement1" would change the level to "Requirement2", and so on.

Is this possible? Or, is it possible to change a key binding dependant on the "Style" within a ".layout" file?

No, I don't think this is possible. You can make a key do different things depending upon whether certain LFUNs are enabled, or whether you are in math, etc, but not this kind of thing, so far as I know.

Then again, if you make the Requirement thing a list environment, maybe it just works?

Richard

Counter requirementCnt


    LabelString          "Requirement: \arabic{requirementCnt}."
End

Counter subrequirementCnt
    Within               requirementCnt
End

Counter subsubrequirementCnt
    Within               subrequirementCnt
End

Counter subsubsubrequirementCnt
    Within               subsubrequirementCnt
End

Style RequirementList
      Category              Requirement
      KeepEmpty             1
      Margin                Dynamic
      LatexType             Command
      LatexName             listofrequirement
      ParIndent             MM
      Align                 Block
      AlignPossible         Block
      LabelType             Static
      LabelString           "--- Requirement List ---"
      LabelFont
        Size                Normal
        Color               Blue
      EndFont
End

AddToPreamble
%%%
% Preamble
%%%
\usepackage{tocloft}
\usepackage{nameref}
\usepackage{refstyle}
\newcommand{\listrequirementname}{List of Requirements}

\newref{req}{%refcmd={#1~Requirement:~\ref{#1},~`\nameref{#1}'}
name = {Requirement~},
names = {Requirement~},
Name = {Requirement~},
Names = {Requirement~},
rngtxt = \RSrngtxt,
lsttwotxt = \RSlsttxt,
lsttxt = \RSlsttxt
}

\newlistof{requirement}{req}{\listrequirementname}
EndPreamble

Style Requirement1
        Category              Requirement
    RefPrefix             req
    TocLevel              0
    LatexType Command
    LatexName requirement
    LabelType Counter
    LabelCounter          requirementCnt
    LabelString           "Requirement \arabic{requirementCnt}: "
    OptionalArgs 1

    LabelSep              xxx
    ParSep                0.7
    Margin                Dynamic
    Font
        Series      Bold
    EndFont
    Preamble
\makeatletter
\newcommand{\requirement}[1]{%
 \def\@currentlabelname{#1}
 \refstepcounter{requirement}
 \par\noindent\textbf{Requirement \therequirement: #1}
 \addcontentsline{req}{requirement}{\protect\numberline{\therequirement}#1}
}
\makeatother

\setcounter{reqdepth}{1}
    EndPreamble
End

Style Requirement2
        Category              Requirement
    RefPrefix             req
    TocLevel              1
    LatexType Command
    LatexName subrequirement
    LabelType Counter

    LabelCounter          subrequirementCnt
LabelString "Requirement \arabic{requirementCnt}.\arabic{subrequirementCnt}: "
    OptionalArgs 1

    LabelSep              xxx
    ParSep                0.7
    Margin                Dynamic
    Font
        Series      Bold
    EndFont
    Preamble
\makeatletter
\newlistentry[requirement]{subrequirement}{req}{1}
\newcommand{\subrequirement}[1]{%
 \def\@currentlabelname{#1}
 \refstepcounter{subrequirement}
 \par\noindent\textbf{Requirement \thesubrequirement: #1}
 
\addcontentsline{req}{subrequirement}{\protect\numberline{\thesubrequirement}#1}
}
\makeatother

\setcounter{reqdepth}{2}
    EndPreamble
End


Style Requirement3
        Category              Requirement
    RefPrefix             req
    TocLevel              2
    LatexType Command
    LatexName subsubrequirement
    LabelType Counter

    LabelCounter          subsubrequirementCnt
LabelString "Requirement \arabic{requirementCnt}.\arabic{subrequirementCnt}.\arabic{subsubrequirementCnt}:"
    OptionalArgs 1

    LabelSep              xxx
    ParSep                0.7
    Margin                Dynamic
    Font
        Series      Bold
    EndFont
    Preamble
\makeatletter
\newlistentry[subrequirement]{subsubrequirement}{req}{1}
\newcommand{\subsubrequirement}[1]{%
 \def\@currentlabelname{#1}
 \refstepcounter{subsubrequirement}
 \par\noindent\textbf{Requirement \thesubsubrequirement: #1}
 
\addcontentsline{req}{subsubrequirement}{\protect\numberline{\thesubsubrequirement}#1}
}
\makeatother

\setcounter{reqdepth}{3}
    EndPreamble
End

Style Requirement4
        Category              Requirement
    RefPrefix             req
    TocLevel              3
    LatexType Command
    LatexName subsubsubrequirement
    LabelType Counter

    LabelCounter          subsubsubrequirementCnt
LabelString "Requirement \arabic{requirementCnt}.\arabic{subrequirementCnt}.\arabic{subsubrequirementCnt}.\arabic{subsubrequirementCnt}:"
    OptionalArgs 1

    LabelSep              xxx
    ParSep                0.7
    Margin                Dynamic
    Font
        Series      Bold
    EndFont
    Preamble
\makeatletter
\newlistentry[subsubrequirement]{subsubsubrequirement}{req}{1}
\cftsetindents{subsubsubrequirement}{1.5em}{3.0em}
\newcommand{\subsubsubrequirement}[1]{%
 \def\@currentlabelname{#1}
 \refstepcounter{subsubsubrequirement}
 \par\noindent\textbf{Requirement \thesubsubsubrequirement: #1}
 
\addcontentsline{req}{subsubsubrequirement}{\protect\numberline{\thesubsubsubrequirement}#1}
}
\makeatother

\setcounter{reqdepth}{4}
    EndPreamble
End


Reply via email to