On Friday 15 May 2009, obregonma...@gmail.com wrote:
> We're getting close!
> 
> On Friday 15 May 2009, Guenter Milde wrote:
> > On 2009-05-15, obregonma...@gmail.com wrote:
> > > On Friday 15 May 2009, Helge Hafting wrote:
> > >> obregonma...@gmail.com wrote:
> > 
> > >> > I want to have a counter (experiment) that uses roman numerals and
> > >> > is sequential throughout the chapters. I figure that a module is the
> > >> > right way about this, so I have a module with the following counter:
> 
> > >> > 3.2    <label expt:reading-ability> Experiment I: Effect of reading 
> > >> > ability
> 
> > > Counter experimentCounter
> > >   LabelString      "\Roman{experimentCounter}"
> > >   Within           ""     
> > > End
> > 
> > This sets up the Counter for LyX only, you need to set up a LaTex
> > counter as well.
> 
> Ah! That explains a lot. 
> 

So, I need to code this for TWO systems: (1) LyX (shown on the screen, with all 
its handy tools); and (2) LaTeX (printed out correctly)!

I have not been able to get the two to happen at the same time. I can get the 
correct solution with the following:

## LyX counter, in correct format:
Counter experimentCounter
        LabelString      "\Roman{experimentCounter}"
        Within           ""     
End

## LaTeX counter, in correct format:
AddToPreamble
                \newcounter{experiment}
                \setcounter{experiment}{0}

                \renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## An LyX style, that just allows me to set a named label for the following 
Experiment heading:
Style ExperimentLabel
        Category                Section
        LatexType               Command
        LatexName               exptLabel
        KeepEmpty               1
        LabelType               Counter
        LeftMargin              XLabel_for_experiment_XXX:XX
        LabelString             "Label for experiment \theexperimentCounter: "
        LabelCounter            experimentCounter
        OptionalArgs            1
        TopSep                  1.4
        Font
                Shape   Italic
                Color   red
                Size            Large
        EndFont
        Preamble
                \newcommand{\exptLabel}[1]{%
                        \refstepcounter{experiment} #1}
        EndPreamble
End

## A new section style, for the correct printing of the experiment title that 
also looks nice on the screen:
Style Experiment
        CopyStyle             Section
        LatexName             experimentSection
        LabelType             Counter
        LabelString           "\thesection  Experiment \theexperimentCounter."
        LabelCounter          section
        OptionalArgs          1
        Font
                Shape   Italic
                Size    Large
        EndFont
        Preamble
          \newcommand{\experimentSection}[1]{%
                \section{\textit{Experiment \theexperiment. #1}}}
        EndPreamble
End


=======================

It took me a long time to find the \refstepcounter{} latex command. It's the 
only way that I've managed to change the label reference environment so that 
the \label{exp:expt-name} takes the experiment counter value and not the 
section counter value.

I don't mind that LyX doesn't show the experiment counter value on the screen, 
but I do need to be able to use labels referring to the experiment counter. I 
tried writing this latex command, but it doesn't work. Anyone know how to write 
this function correctly?

          \newcommand{\experimentSection}[1]{%
                \section{\textit{Experiment \theexperiment. 
{\refstepcounter{experiment} #1}}}}

Thanks.

Mateo.

Reply via email to