1
votes

I have a custom layout that adds a "field" style to LyX. Each time a "field" is created, I'd like to also have a corresponding label attached to the "field" in LyX. Is there a way to do this programmatically in LyX?

Counter fieldCnt
LabelString          "Field: \arabic{fieldCnt}."
PrettyFormat         "Field: ##"
End

AddToPreamble

\usepackage{tocloft}
\usepackage{ifthen}
\usepackage{nameref}%
\usepackage{hyperref}%
%\usepackage{refstyle}
\newcommand{\listfieldname}{List of Fields}

\newref{field}{ %
%refcmd = {\ref{#1}, `\nameref{#1}'},
name = {Field~},
names = {Field~},
Name = {Field~},
Names = {Field~},
rngtxt = \RSrngtxt,
lsttxt = \RSlsttxt
}

EndPreamble

Style Field1
Category              Field
RefPrefix field
LatexType Command
LatexName field
LabelType Counter
LabelCounter          fieldCnt
LabelString           "Field \arabic{fieldCnt}: "
OptionalArgs 1

LabelSep              xxx
ParSep                0.7
Margin                Dynamic
Font
Series      Bold
EndFont
Preamble
\newlistof{field}{field}{\listfieldname}
\newcommand{\field}[1]{%
 \refstepcounter{field}
 \par\noindent\textbf{Field \thefield: #1}
 \addcontentsline{field}{field}{\protect\numberline{\thefield}#1}\par}

\setcounter{fielddepth}{1}
EndPreamble
End
1

1 Answers

0
votes

There is no means by which LyX code can be added in style section of the layout file.