Re: Using counters

2009-05-20 Thread Pavel Sanda
obregonma...@gmail.com wrote:
 Perhaps we need a bit more documentation on how to use modules to set-up 
 specific behaviours in both LyX and LaTeX.

and good start is to put up what you have learned somewhere in the wiki.
pavel


Re: Using counters

2009-05-20 Thread Pavel Sanda
obregonma...@gmail.com wrote:
 Perhaps we need a bit more documentation on how to use modules to set-up 
 specific behaviours in both LyX and LaTeX.

and good start is to put up what you have learned somewhere in the wiki.
pavel


Re: Using counters

2009-05-20 Thread Pavel Sanda
obregonma...@gmail.com wrote:
> Perhaps we need a bit more documentation on how to use modules to set-up 
> specific behaviours in both LyX and LaTeX.

and good start is to put up what you have learned somewhere in the wiki.
pavel


Re: Using counters

2009-05-19 Thread Guenter Milde
On 2009-05-18, Helge Hafting wrote:
 obregonma...@gmail.com wrote:
 On Friday 15 May 2009, 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:


 Yes. You have to use refstepcounter inside your \experimentSection 
 command. This increments the counter for you, and also sets the 
 reference string so that the next label will get the experiment number 
 instead of the section number. Note that \refstepcounter won't work
 inside a \section command though. (latex limitation)

 The whole module looks like this:

...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


 And we also have to use \stepcounter _before_ the section, 
 so that the printed number won't be one too low.
...
 I know of no way to set the reference string _without_ also incrementing 
 the counter. Such a command would make things simpler, but I don't think 
 it exists.

I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.

...

 if you insert a label in the text following an experiment line, then any 
 cross reference to that label will print the roman numeral for the 
 experiment.

 If you put a label inside the experiment line itself, then cross 
 references to that internal label will print the experiment's section 
 number. So be careful how you place your labels!

Günter



Re: Using counters

2009-05-19 Thread Helge Hafting

Guenter Milde wrote:

On 2009-05-18, Helge Hafting wrote:

obregonma...@gmail.com wrote:

On Friday 15 May 2009, 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:



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)



The whole module looks like this:


...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


And we also have to use \stepcounter _before_ the section, 
so that the printed number won't be one too low.

...
I know of no way to set the reference string _without_ also incrementing 
the counter. Such a command would make things simpler, but I don't think 
it exists.


I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.


I tried that during my testing, but the problem is that references to
any label inside such a experiment will be off by one!

See experiment 8 when the label is in experiment 7 is not useful. 
Everything will seem fine as long as you don't use cross-references.


Helge Hafting


Re: Using counters

2009-05-19 Thread obregonmateo
Many thanks to all (especially Günter and Helge) for helping me solve this 
issue of having different counters throughout a document. This has also helped 
me understand how LyX behaviour has be coded to mirror the desired LaTeX 
behaviour, and how the LyX modules design is so useful for this.

Perhaps we need a bit more documentation on how to use modules to set-up 
specific behaviours in both LyX and LaTeX.

Cheers.

Mateo.

On Tuesday 19 May 2009, Helge Hafting wrote:
 Guenter Milde wrote:
  On 2009-05-18, Helge Hafting wrote:
  obregonma...@gmail.com wrote:
  On Friday 15 May 2009, 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:
  
  
  Yes. You have to use refstepcounter inside your \experimentSection 
  command. This increments the counter for you, and also sets the 
  reference string so that the next label will get the experiment number 
  instead of the section number. Note that \refstepcounter won't work
  inside a \section command though. (latex limitation)
  
  The whole module looks like this:
  
  ...
  
  It can be slightly simplified:
  
  #\DeclareLyXModule{testexperiment}
  #This is a test!
  
  AddToPreamble
  \newcounter{experiment}\setcounter{experiment}{1}
  \renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
  EndPreamble
  
  ## 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\theexperiment.
  LabelCounter  section
  OptionalArgs  1
  Font
  Shape   Italic
  SizeLarge
  EndFont
   Preamble
\newcommand{\experimentSection}[1]{%
  \section{\textit{Experiment \theexperiment. #1}}
  \refstepcounter{experiment}
}
  EndPreamble
  End
  
  
  And we also have to use \stepcounter _before_ the section, 
  so that the printed number won't be one too low.
  ...
  I know of no way to set the reference string _without_ also incrementing 
  the counter. Such a command would make things simpler, but I don't think 
  it exists.
  
  I just start the counter wiht 1 instead of 0, so it is correct
  *before* \refstepcounter is applied.
  
 I tried that during my testing, but the problem is that references to
 any label inside such a experiment will be off by one!
 
 See experiment 8 when the label is in experiment 7 is not useful. 
 Everything will seem fine as long as you don't use cross-references.
 
 Helge Hafting
 




Re: Using counters

2009-05-19 Thread Guenter Milde
On 2009-05-18, Helge Hafting wrote:
 obregonma...@gmail.com wrote:
 On Friday 15 May 2009, 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:


 Yes. You have to use refstepcounter inside your \experimentSection 
 command. This increments the counter for you, and also sets the 
 reference string so that the next label will get the experiment number 
 instead of the section number. Note that \refstepcounter won't work
 inside a \section command though. (latex limitation)

 The whole module looks like this:

...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


 And we also have to use \stepcounter _before_ the section, 
 so that the printed number won't be one too low.
...
 I know of no way to set the reference string _without_ also incrementing 
 the counter. Such a command would make things simpler, but I don't think 
 it exists.

I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.

...

 if you insert a label in the text following an experiment line, then any 
 cross reference to that label will print the roman numeral for the 
 experiment.

 If you put a label inside the experiment line itself, then cross 
 references to that internal label will print the experiment's section 
 number. So be careful how you place your labels!

Günter



Re: Using counters

2009-05-19 Thread Helge Hafting

Guenter Milde wrote:

On 2009-05-18, Helge Hafting wrote:

obregonma...@gmail.com wrote:

On Friday 15 May 2009, 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:



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)



The whole module looks like this:


...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


And we also have to use \stepcounter _before_ the section, 
so that the printed number won't be one too low.

...
I know of no way to set the reference string _without_ also incrementing 
the counter. Such a command would make things simpler, but I don't think 
it exists.


I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.


I tried that during my testing, but the problem is that references to
any label inside such a experiment will be off by one!

See experiment 8 when the label is in experiment 7 is not useful. 
Everything will seem fine as long as you don't use cross-references.


Helge Hafting


Re: Using counters

2009-05-19 Thread obregonmateo
Many thanks to all (especially Günter and Helge) for helping me solve this 
issue of having different counters throughout a document. This has also helped 
me understand how LyX behaviour has be coded to mirror the desired LaTeX 
behaviour, and how the LyX modules design is so useful for this.

Perhaps we need a bit more documentation on how to use modules to set-up 
specific behaviours in both LyX and LaTeX.

Cheers.

Mateo.

On Tuesday 19 May 2009, Helge Hafting wrote:
 Guenter Milde wrote:
  On 2009-05-18, Helge Hafting wrote:
  obregonma...@gmail.com wrote:
  On Friday 15 May 2009, 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:
  
  
  Yes. You have to use refstepcounter inside your \experimentSection 
  command. This increments the counter for you, and also sets the 
  reference string so that the next label will get the experiment number 
  instead of the section number. Note that \refstepcounter won't work
  inside a \section command though. (latex limitation)
  
  The whole module looks like this:
  
  ...
  
  It can be slightly simplified:
  
  #\DeclareLyXModule{testexperiment}
  #This is a test!
  
  AddToPreamble
  \newcounter{experiment}\setcounter{experiment}{1}
  \renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
  EndPreamble
  
  ## 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\theexperiment.
  LabelCounter  section
  OptionalArgs  1
  Font
  Shape   Italic
  SizeLarge
  EndFont
   Preamble
\newcommand{\experimentSection}[1]{%
  \section{\textit{Experiment \theexperiment. #1}}
  \refstepcounter{experiment}
}
  EndPreamble
  End
  
  
  And we also have to use \stepcounter _before_ the section, 
  so that the printed number won't be one too low.
  ...
  I know of no way to set the reference string _without_ also incrementing 
  the counter. Such a command would make things simpler, but I don't think 
  it exists.
  
  I just start the counter wiht 1 instead of 0, so it is correct
  *before* \refstepcounter is applied.
  
 I tried that during my testing, but the problem is that references to
 any label inside such a experiment will be off by one!
 
 See experiment 8 when the label is in experiment 7 is not useful. 
 Everything will seem fine as long as you don't use cross-references.
 
 Helge Hafting
 




Re: Using counters

2009-05-19 Thread Guenter Milde
On 2009-05-18, Helge Hafting wrote:
> obregonma...@gmail.com wrote:
>> On Friday 15 May 2009, 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:


> Yes. You have to use refstepcounter inside your \experimentSection 
> command. This increments the counter for you, and also sets the 
> reference string so that the next label will get the experiment number 
> instead of the section number. Note that \refstepcounter won't work
> inside a \section command though. (latex limitation)

> The whole module looks like this:

...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment."
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


> And we also have to use \stepcounter _before_ the section, 
> so that the printed number won't be one too low.
...
> I know of no way to set the reference string _without_ also incrementing 
> the counter. Such a command would make things simpler, but I don't think 
> it exists.

I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.

...

> if you insert a label in the text following an experiment line, then any 
> cross reference to that label will print the roman numeral for the 
> experiment.

> If you put a label inside the experiment line itself, then cross 
> references to that internal label will print the experiment's section 
> number. So be careful how you place your labels!

Günter



Re: Using counters

2009-05-19 Thread Helge Hafting

Guenter Milde wrote:

On 2009-05-18, Helge Hafting wrote:

obregonma...@gmail.com wrote:

On Friday 15 May 2009, 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:



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)



The whole module looks like this:


...

It can be slightly simplified:

#\DeclareLyXModule{testexperiment}
#This is a test!

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{1}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment."
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
 Preamble
  \newcommand{\experimentSection}[1]{%
\section{\textit{Experiment \theexperiment. #1}}
\refstepcounter{experiment}
  }
EndPreamble
End


And we also have to use \stepcounter _before_ the section, 
so that the printed number won't be one too low.

...
I know of no way to set the reference string _without_ also incrementing 
the counter. Such a command would make things simpler, but I don't think 
it exists.


I just start the counter wiht 1 instead of 0, so it is correct
*before* \refstepcounter is applied.


I tried that during my testing, but the problem is that references to
any label inside such a "experiment" will be off by one!

"See experiment 8" when the label is in "experiment 7" is not useful. 
Everything will seem fine as long as you don't use cross-references.


Helge Hafting


Re: Using counters

2009-05-19 Thread obregonmateo
Many thanks to all (especially Günter and Helge) for helping me solve this 
issue of having different counters throughout a document. This has also helped 
me understand how LyX behaviour has be coded to mirror the desired LaTeX 
behaviour, and how the LyX modules design is so useful for this.

Perhaps we need a bit more documentation on how to use modules to set-up 
specific behaviours in both LyX and LaTeX.

Cheers.

Mateo.

On Tuesday 19 May 2009, Helge Hafting wrote:
> Guenter Milde wrote:
> > On 2009-05-18, Helge Hafting wrote:
> >> obregonma...@gmail.com wrote:
> >>> On Friday 15 May 2009, 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:
> > 
> > 
> >> Yes. You have to use refstepcounter inside your \experimentSection 
> >> command. This increments the counter for you, and also sets the 
> >> reference string so that the next label will get the experiment number 
> >> instead of the section number. Note that \refstepcounter won't work
> >> inside a \section command though. (latex limitation)
> > 
> >> The whole module looks like this:
> > 
> > ...
> > 
> > It can be slightly simplified:
> > 
> > #\DeclareLyXModule{testexperiment}
> > #This is a test!
> > 
> > AddToPreamble
> > \newcounter{experiment}\setcounter{experiment}{1}
> > \renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
> > EndPreamble
> > 
> > ## 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\theexperiment."
> > LabelCounter  section
> > OptionalArgs  1
> > Font
> > Shape   Italic
> > SizeLarge
> > EndFont
> >  Preamble
> >   \newcommand{\experimentSection}[1]{%
> > \section{\textit{Experiment \theexperiment. #1}}
> > \refstepcounter{experiment}
> >   }
> > EndPreamble
> > End
> > 
> > 
> >> And we also have to use \stepcounter _before_ the section, 
> >> so that the printed number won't be one too low.
> > ...
> >> I know of no way to set the reference string _without_ also incrementing 
> >> the counter. Such a command would make things simpler, but I don't think 
> >> it exists.
> > 
> > I just start the counter wiht 1 instead of 0, so it is correct
> > *before* \refstepcounter is applied.
> > 
> I tried that during my testing, but the problem is that references to
> any label inside such a "experiment" will be off by one!
> 
> "See experiment 8" when the label is in "experiment 7" is not useful. 
> Everything will seem fine as long as you don't use cross-references.
> 
> Helge Hafting
> 




Re: Using counters

2009-05-18 Thread Helge Hafting

obregonma...@gmail.com wrote:

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.2label 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString Label for experiment \theexperimentCounter: 
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)

The whole module looks like this:

#\DeclareLyXModule{testexperiment}
#This is a test!
Format 11
Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within  
End

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{0}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
Preamble
  \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \theexperiment. #1}}
\addtocounter{experiment}{-1}

Re: Using counters

2009-05-18 Thread Helge Hafting

obregonma...@gmail.com wrote:

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.2label 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString Label for experiment \theexperimentCounter: 
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)

The whole module looks like this:

#\DeclareLyXModule{testexperiment}
#This is a test!
Format 11
Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within  
End

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{0}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment.
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
Preamble
  \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \theexperiment. #1}}
\addtocounter{experiment}{-1}

Re: Using counters

2009-05-18 Thread Helge Hafting

obregonma...@gmail.com wrote:

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 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString "Label for experiment \theexperimentCounter: "
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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



Yes. You have to use refstepcounter inside your \experimentSection 
command. This increments the counter for you, and also sets the 
reference string so that the next label will get the experiment number 
instead of the section number. Note that \refstepcounter won't work

inside a \section command though. (latex limitation)

The whole module looks like this:

#\DeclareLyXModule{testexperiment}
#This is a test!
Format 11
Counter experimentCounter
LabelString  "\Roman{experimentCounter}"
Within   ""   
End

AddToPreamble
\newcounter{experiment}\setcounter{experiment}{0}
\renewcommand{\theexperiment}{\textit{\Roman{experiment}}}
EndPreamble

## 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\theexperiment."
LabelCounter  section
OptionalArgs  1
Font
Shape   Italic
SizeLarge
EndFont
Preamble
  \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \theexperiment. #1}}
\addtocounter{experiment}{-1}

Re: Using counters

2009-05-17 Thread obregonmateo
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.2label 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString Label for experiment \theexperimentCounter: 
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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.



Re: Using counters

2009-05-17 Thread obregonmateo
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.2label 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString Label for experiment \theexperimentCounter: 
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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.



Re: Using counters

2009-05-17 Thread obregonmateo
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 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
CategorySection
LatexType   Command
LatexName   exptLabel
KeepEmpty   1
LabelType   Counter
LeftMargin  XLabel_for_experiment_XXX:XX
LabelString "Label for experiment \theexperimentCounter: "
LabelCounterexperimentCounter
OptionalArgs1
TopSep  1.4
Font
Shape   Italic
Color   red
SizeLarge
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
SizeLarge
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.



Re: Using counters

2009-05-15 Thread Helge Hafting

obregonma...@gmail.com wrote:

Hi everyone-

I've gone through the docs, wikis and examples, and I need a helping hand.

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:

Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within  
End

Now, what I want is a section heading  that would look like:

3.2label expt:reading-ability Experiment I: Effect of reading ability

and then later on:

3.6   label expt:age-predictor Experiment II: Age as a predictor

and then ...

4.2   label expt:reading-aids Experiment III: Reading aids



How can I use my experimentCounter in a section title, as well as assign a label to this experiment item (NOT the section number)? I imagine that it would require an ERT ... but with what LaTeX command? 



Sure, this can be done with some ERT.
But if you're making a module anyway, why not implement this too in the 
module?


Basically, you create a new experiment-section that contains all the 
stuff from a regular section ( copy it out of stdsections.inc, or use
CopyStyle Section and take it from there.) And then you add the 
necessary latex code, once. Instead of having to add it as ERT to

every experiment in your text.

So when you start a new experiment, you use experiment-section instead
of a regular section. I am not sure if you can get LyX to display the 
experiment counter in the edit window, as incrementing two counters at 
once is a bit unusual. But it should definitely work for output!


As for the actual latex code needed to increment and display the 
counter, I don't have time to look that up right now. Look for

examples on the net, or borrow one of the recommended latex books at
a library.

Helge Hafting



Re: Using counters

2009-05-15 Thread obregonmateo


On Friday 15 May 2009, Helge Hafting wrote:
 obregonma...@gmail.com wrote:
  I've gone through the docs, wikis and examples, and I need a helping hand.
  
  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:
  
  Counter experimentCounter
  LabelString  \Roman{experimentCounter}
  Within
  End
  
  Now, what I want is a section heading  that would look like:
  
  3.2label expt:reading-ability Experiment I: Effect of reading ability
  
  and then later on:
  
  3.6   label expt:age-predictor Experiment II: Age as a predictor
  
  and then ...
  
  4.2   label expt:reading-aids Experiment III: Reading aids
  
  
  
  How can I use my experimentCounter in a section title, as well as assign 
  a label to this experiment item (NOT the section number)? I imagine that it 
  would require an ERT ... but with what LaTeX command? 
  
 
 Basically, you create a new experiment-section that contains all the 
 stuff from a regular section ( copy it out of stdsections.inc, or use
 CopyStyle Section and take it from there.) And then you add the 
 necessary latex code, once. Instead of having to add it as ERT to
 every experiment in your text.
 
 So when you start a new experiment, you use experiment-section instead
 of a regular section. I am not sure if you can get LyX to display the 
 experiment counter in the edit window, as incrementing two counters at 
 once is a bit unusual. But it should definitely work for output!

I can get LyX to display a modified section very nicely, but I cannot get latex 
to show me a modified experiment-section.

 As for the actual latex code needed to increment and display the 
 counter, I don't have time to look that up right now. Look for
 examples on the net, or borrow one of the recommended latex books at
 a library.

I am at a loss for the latex commands. I don't want to start learning the 
complexities of LaTeX macro writings just to modify a section title. I looked 
at the sectsty.sty and titlesec.sty documentation and found them not to be of 
help. One changes all sections and the other you have to know a lot of LaTex. I 
simply want something like this, so that I have both the normal section counter 
and my special experimentCounter counter:

Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within
End

Style Experiment
CopyStyle Section
LatexName experiment-section
LabelType Counter
LabelString   Experiment \theexperimentCounter.
LabelCounter  section, experimentCounter
Font
Series  Italic
SizeLarge
EndFont
Preamble
\newcommand{\experiment-section}[1]{%
\section{Experiment \theexperimentCounter. #1}}
EndPreamble
End

But, latex gives errors that I don't understand. 


Re: Using counters

2009-05-15 Thread Guenter Milde
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:
  
  Counter experimentCounter
 LabelString  \Roman{experimentCounter}
 Within
  End
  
  Now, what I want is a section heading  that would look like:
  
  3.2label expt:reading-ability Experiment I: Effect of reading ability
  
  and then later on:
  
  3.6   label expt:age-predictor Experiment II: Age as a predictor
  
  and then ...
  
  4.2   label expt:reading-aids Experiment III: Reading aids
  
  
  
  How can I use my experimentCounter in a section title, as well as
  assign a label to this experiment item (NOT the section number)? I
  imagine that it would require an ERT ... but with what LaTeX
  command? 


 Basically, you create a new experiment-section [...] And then you add
 the necessary latex code, once. Instead of having to add it as ERT to
 every experiment in your text.

 I can get LyX to display a modified section very nicely, but I cannot
 get latex to show me a modified experiment-section.

...

 I am at a loss for the latex commands. I don't want to start learning
 the complexities of LaTeX macro writings just to modify a section
 title. 

In this case you might consider typing the Experiment number by hand...

 I simply want something like this, so that I have both the normal
 section counter and my special experimentCounter counter:

 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.

AddToPreamble
\newcounter{experiment}
\setcounter{experiment}{0}
EndPreamble


 Style Experiment
 CopyStyle Section
   LatexName experiment-section
 LabelType Counter
 LabelString   Experiment \theexperimentCounter.
 LabelCountersection, experimentCounter
   Font
   Series  Italic
   SizeLarge
   EndFont
 Preamble
   \newcommand{\experiment-section}[1]{%
   \section{Experiment \theexperimentCounter. #1}}
   EndPreamble
 End

 But, latex gives errors that I don't understand.

But only if you post them here, we can help!

1. LaTeX macro names with hyphens are not strictly forbidden but only
   accessible with the \csname ... \endcsname construct.
   
   Use e.g. \experimentSection
   
2. As already said, you need to set up the counter for LaTeX as well.

3. You need to increment the counter in LaTeX
   
4. You need to convert the counter to Roman in LaTeX

Maybe this works, but it is untested:
 
 \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{Experiment \Roman{experiment}. #1}%
 }
   
Günter



Re: Using counters

2009-05-15 Thread obregonmateo
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.2label expt:reading-ability Experiment I: Effect of reading 
   ability
 
  I am at a loss for the latex commands. I don't want to start learning
  the complexities of LaTeX macro writings just to modify a section
  title. 
 
 In this case you might consider typing the Experiment number by hand...

I have considered this ... but I'm convinced that there is a better way, as I 
have 10 experiment to report and refer to throughout my long document.

  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. 

 AddToPreamble
 \newcounter{experiment}
   \setcounter{experiment}{0}
 EndPreamble

Progress. :)

 Maybe this works, but it is untested:
  
  \newcommand{\experimentSection}[1]{%
 \stepcounter{experiment}
 \section{Experiment \Roman{experiment}. #1}%
  }

Yes, the correct section label is generated by latex. And, I've modified the 
LyX Experiment style to show me something workable too (\theexperimentCounter 
below just gives me ?? in the document).

Style Experiment
CopyStyle Section
LatexName experimentSection
LabelType Counter
LabelString   \thesection  Experiment \theexperimentCounter.
LabelCounter  section
Font
Shape   Italic
SizeLarge
EndFont
Preamble
\newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \Roman{experiment}. #1}}%
 }
EndPreamble
End

Now, I need a way to create a label in LyX that refers to value of the 
experiment counter. This way, I can refer to the different experiments in 
text by label (and page, etc).

Thanks Guenter for your help so far. I hope you have a solution for this 
question too.

Mateo.


Re: Using counters

2009-05-15 Thread Helge Hafting

obregonma...@gmail.com wrote:

Hi everyone-

I've gone through the docs, wikis and examples, and I need a helping hand.

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:

Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within  
End

Now, what I want is a section heading  that would look like:

3.2label expt:reading-ability Experiment I: Effect of reading ability

and then later on:

3.6   label expt:age-predictor Experiment II: Age as a predictor

and then ...

4.2   label expt:reading-aids Experiment III: Reading aids



How can I use my experimentCounter in a section title, as well as assign a label to this experiment item (NOT the section number)? I imagine that it would require an ERT ... but with what LaTeX command? 



Sure, this can be done with some ERT.
But if you're making a module anyway, why not implement this too in the 
module?


Basically, you create a new experiment-section that contains all the 
stuff from a regular section ( copy it out of stdsections.inc, or use
CopyStyle Section and take it from there.) And then you add the 
necessary latex code, once. Instead of having to add it as ERT to

every experiment in your text.

So when you start a new experiment, you use experiment-section instead
of a regular section. I am not sure if you can get LyX to display the 
experiment counter in the edit window, as incrementing two counters at 
once is a bit unusual. But it should definitely work for output!


As for the actual latex code needed to increment and display the 
counter, I don't have time to look that up right now. Look for

examples on the net, or borrow one of the recommended latex books at
a library.

Helge Hafting



Re: Using counters

2009-05-15 Thread obregonmateo


On Friday 15 May 2009, Helge Hafting wrote:
 obregonma...@gmail.com wrote:
  I've gone through the docs, wikis and examples, and I need a helping hand.
  
  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:
  
  Counter experimentCounter
  LabelString  \Roman{experimentCounter}
  Within
  End
  
  Now, what I want is a section heading  that would look like:
  
  3.2label expt:reading-ability Experiment I: Effect of reading ability
  
  and then later on:
  
  3.6   label expt:age-predictor Experiment II: Age as a predictor
  
  and then ...
  
  4.2   label expt:reading-aids Experiment III: Reading aids
  
  
  
  How can I use my experimentCounter in a section title, as well as assign 
  a label to this experiment item (NOT the section number)? I imagine that it 
  would require an ERT ... but with what LaTeX command? 
  
 
 Basically, you create a new experiment-section that contains all the 
 stuff from a regular section ( copy it out of stdsections.inc, or use
 CopyStyle Section and take it from there.) And then you add the 
 necessary latex code, once. Instead of having to add it as ERT to
 every experiment in your text.
 
 So when you start a new experiment, you use experiment-section instead
 of a regular section. I am not sure if you can get LyX to display the 
 experiment counter in the edit window, as incrementing two counters at 
 once is a bit unusual. But it should definitely work for output!

I can get LyX to display a modified section very nicely, but I cannot get latex 
to show me a modified experiment-section.

 As for the actual latex code needed to increment and display the 
 counter, I don't have time to look that up right now. Look for
 examples on the net, or borrow one of the recommended latex books at
 a library.

I am at a loss for the latex commands. I don't want to start learning the 
complexities of LaTeX macro writings just to modify a section title. I looked 
at the sectsty.sty and titlesec.sty documentation and found them not to be of 
help. One changes all sections and the other you have to know a lot of LaTex. I 
simply want something like this, so that I have both the normal section counter 
and my special experimentCounter counter:

Counter experimentCounter
LabelString  \Roman{experimentCounter}
Within
End

Style Experiment
CopyStyle Section
LatexName experiment-section
LabelType Counter
LabelString   Experiment \theexperimentCounter.
LabelCounter  section, experimentCounter
Font
Series  Italic
SizeLarge
EndFont
Preamble
\newcommand{\experiment-section}[1]{%
\section{Experiment \theexperimentCounter. #1}}
EndPreamble
End

But, latex gives errors that I don't understand. 


Re: Using counters

2009-05-15 Thread Guenter Milde
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:
  
  Counter experimentCounter
 LabelString  \Roman{experimentCounter}
 Within
  End
  
  Now, what I want is a section heading  that would look like:
  
  3.2label expt:reading-ability Experiment I: Effect of reading ability
  
  and then later on:
  
  3.6   label expt:age-predictor Experiment II: Age as a predictor
  
  and then ...
  
  4.2   label expt:reading-aids Experiment III: Reading aids
  
  
  
  How can I use my experimentCounter in a section title, as well as
  assign a label to this experiment item (NOT the section number)? I
  imagine that it would require an ERT ... but with what LaTeX
  command? 


 Basically, you create a new experiment-section [...] And then you add
 the necessary latex code, once. Instead of having to add it as ERT to
 every experiment in your text.

 I can get LyX to display a modified section very nicely, but I cannot
 get latex to show me a modified experiment-section.

...

 I am at a loss for the latex commands. I don't want to start learning
 the complexities of LaTeX macro writings just to modify a section
 title. 

In this case you might consider typing the Experiment number by hand...

 I simply want something like this, so that I have both the normal
 section counter and my special experimentCounter counter:

 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.

AddToPreamble
\newcounter{experiment}
\setcounter{experiment}{0}
EndPreamble


 Style Experiment
 CopyStyle Section
   LatexName experiment-section
 LabelType Counter
 LabelString   Experiment \theexperimentCounter.
 LabelCountersection, experimentCounter
   Font
   Series  Italic
   SizeLarge
   EndFont
 Preamble
   \newcommand{\experiment-section}[1]{%
   \section{Experiment \theexperimentCounter. #1}}
   EndPreamble
 End

 But, latex gives errors that I don't understand.

But only if you post them here, we can help!

1. LaTeX macro names with hyphens are not strictly forbidden but only
   accessible with the \csname ... \endcsname construct.
   
   Use e.g. \experimentSection
   
2. As already said, you need to set up the counter for LaTeX as well.

3. You need to increment the counter in LaTeX
   
4. You need to convert the counter to Roman in LaTeX

Maybe this works, but it is untested:
 
 \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{Experiment \Roman{experiment}. #1}%
 }
   
Günter



Re: Using counters

2009-05-15 Thread obregonmateo
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.2label expt:reading-ability Experiment I: Effect of reading 
   ability
 
  I am at a loss for the latex commands. I don't want to start learning
  the complexities of LaTeX macro writings just to modify a section
  title. 
 
 In this case you might consider typing the Experiment number by hand...

I have considered this ... but I'm convinced that there is a better way, as I 
have 10 experiment to report and refer to throughout my long document.

  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. 

 AddToPreamble
 \newcounter{experiment}
   \setcounter{experiment}{0}
 EndPreamble

Progress. :)

 Maybe this works, but it is untested:
  
  \newcommand{\experimentSection}[1]{%
 \stepcounter{experiment}
 \section{Experiment \Roman{experiment}. #1}%
  }

Yes, the correct section label is generated by latex. And, I've modified the 
LyX Experiment style to show me something workable too (\theexperimentCounter 
below just gives me ?? in the document).

Style Experiment
CopyStyle Section
LatexName experimentSection
LabelType Counter
LabelString   \thesection  Experiment \theexperimentCounter.
LabelCounter  section
Font
Shape   Italic
SizeLarge
EndFont
Preamble
\newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \Roman{experiment}. #1}}%
 }
EndPreamble
End

Now, I need a way to create a label in LyX that refers to value of the 
experiment counter. This way, I can refer to the different experiments in 
text by label (and page, etc).

Thanks Guenter for your help so far. I hope you have a solution for this 
question too.

Mateo.


Re: Using counters

2009-05-15 Thread Helge Hafting

obregonma...@gmail.com wrote:

Hi everyone-

I've gone through the docs, wikis and examples, and I need a helping hand.

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:

Counter experimentCounter
LabelString  "\Roman{experimentCounter}"
Within   ""   
End

Now, what I want is a section heading  that would look like:

3.2 Experiment I: Effect of reading ability

and then later on:

3.6Experiment II: Age as a predictor

and then ...

4.2Experiment III: Reading aids



How can I use my "experimentCounter" in a section title, as well as assign a label to this experiment item (NOT the section number)? I imagine that it would require an ERT ... but with what LaTeX command? 



Sure, this can be done with some ERT.
But if you're making a module anyway, why not implement this too in the 
module?


Basically, you create a new "experiment-section" that contains all the 
stuff from a regular "section" ( copy it out of stdsections.inc, or use
"CopyStyle Section" and take it from there.) And then you add the 
necessary latex code, once. Instead of having to add it as ERT to

every experiment in your text.

So when you start a new experiment, you use "experiment-section" instead
of a regular section. I am not sure if you can get LyX to display the 
experiment counter in the edit window, as incrementing two counters at 
once is a bit unusual. But it should definitely work for output!


As for the actual latex code needed to increment and display the 
counter, I don't have time to look that up right now. Look for

examples on the net, or borrow one of the recommended latex books at
a library.

Helge Hafting



Re: Using counters

2009-05-15 Thread obregonmateo


On Friday 15 May 2009, Helge Hafting wrote:
> obregonma...@gmail.com wrote:
> > I've gone through the docs, wikis and examples, and I need a helping hand.
> > 
> > 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:
> > 
> > Counter experimentCounter
> > LabelString  "\Roman{experimentCounter}"
> > Within   "" 
> > End
> > 
> > Now, what I want is a section heading  that would look like:
> > 
> > 3.2 Experiment I: Effect of reading ability
> > 
> > and then later on:
> > 
> > 3.6Experiment II: Age as a predictor
> > 
> > and then ...
> > 
> > 4.2Experiment III: Reading aids
> > 
> > 
> > 
> > How can I use my "experimentCounter" in a section title, as well as assign 
> > a label to this experiment item (NOT the section number)? I imagine that it 
> > would require an ERT ... but with what LaTeX command? 
> > 
> 
> Basically, you create a new "experiment-section" that contains all the 
> stuff from a regular "section" ( copy it out of stdsections.inc, or use
> "CopyStyle Section" and take it from there.) And then you add the 
> necessary latex code, once. Instead of having to add it as ERT to
> every experiment in your text.
> 
> So when you start a new experiment, you use "experiment-section" instead
> of a regular section. I am not sure if you can get LyX to display the 
> experiment counter in the edit window, as incrementing two counters at 
> once is a bit unusual. But it should definitely work for output!

I can get LyX to display a modified section very nicely, but I cannot get latex 
to show me a modified experiment-section.

> As for the actual latex code needed to increment and display the 
> counter, I don't have time to look that up right now. Look for
> examples on the net, or borrow one of the recommended latex books at
> a library.

I am at a loss for the latex commands. I don't want to start learning the 
complexities of LaTeX macro writings just to modify a section title. I looked 
at the sectsty.sty and titlesec.sty documentation and found them not to be of 
help. One changes all sections and the other you have to know a lot of LaTex. I 
simply want something like this, so that I have both the normal section counter 
and my special experimentCounter counter:

Counter experimentCounter
LabelString  "\Roman{experimentCounter}"
Within   "" 
End

Style Experiment
CopyStyle Section
LatexName experiment-section
LabelType Counter
LabelString   "Experiment \theexperimentCounter."
LabelCounter  section, experimentCounter
Font
Series  Italic
SizeLarge
EndFont
Preamble
\newcommand{\experiment-section}[1]{%
\section{Experiment \theexperimentCounter. #1}}
EndPreamble
End

But, latex gives errors that I don't understand. 


Re: Using counters

2009-05-15 Thread Guenter Milde
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:
>> > 
>> > Counter experimentCounter
>> >LabelString  "\Roman{experimentCounter}"
>> >Within   "" 
>> > End
>> > 
>> > Now, what I want is a section heading  that would look like:
>> > 
>> > 3.2 Experiment I: Effect of reading ability
>> > 
>> > and then later on:
>> > 
>> > 3.6Experiment II: Age as a predictor
>> > 
>> > and then ...
>> > 
>> > 4.2Experiment III: Reading aids
>> > 
>> > 
>> > 
>> > How can I use my "experimentCounter" in a section title, as well as
>> > assign a label to this experiment item (NOT the section number)? I
>> > imagine that it would require an ERT ... but with what LaTeX
>> > command? 


>> Basically, you create a new "experiment-section" [...] And then you add
>> the necessary latex code, once. Instead of having to add it as ERT to
>> every experiment in your text.

> I can get LyX to display a modified section very nicely, but I cannot
> get latex to show me a modified experiment-section.

...

> I am at a loss for the latex commands. I don't want to start learning
> the complexities of LaTeX macro writings just to modify a section
> title. 

In this case you might consider typing the Experiment number by hand...

> I simply want something like this, so that I have both the normal
> section counter and my special experimentCounter counter:

> 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.

AddToPreamble
\newcounter{experiment}
\setcounter{experiment}{0}
EndPreamble


> Style Experiment
> CopyStyle Section
>   LatexName experiment-section
> LabelType Counter
> LabelString   "Experiment \theexperimentCounter."
> LabelCountersection, experimentCounter
>   Font
>   Series  Italic
>   SizeLarge
>   EndFont
> Preamble
>   \newcommand{\experiment-section}[1]{%
>   \section{Experiment \theexperimentCounter. #1}}
>   EndPreamble
> End

> But, latex gives errors that I don't understand.

But only if you post them here, we can help!

1. LaTeX macro names with hyphens are not strictly forbidden but only
   accessible with the \csname ... \endcsname construct.
   
   Use e.g. \experimentSection
   
2. As already said, you need to set up the counter for LaTeX as well.

3. You need to increment the counter in LaTeX
   
4. You need to convert the counter to Roman in LaTeX

Maybe this works, but it is untested:
 
 \newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{Experiment \Roman{experiment}. #1}%
 }
   
Günter



Re: Using counters

2009-05-15 Thread obregonmateo
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 Experiment I: Effect of reading 
> >> > ability
> 
> > I am at a loss for the latex commands. I don't want to start learning
> > the complexities of LaTeX macro writings just to modify a section
> > title. 
> 
> In this case you might consider typing the Experiment number by hand...

I have considered this ... but I'm convinced that there is a better way, as I 
have 10 experiment to report and refer to throughout my long document.

> > 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. 

> AddToPreamble
> \newcounter{experiment}
>   \setcounter{experiment}{0}
> EndPreamble

Progress. :)

> Maybe this works, but it is untested:
>  
>  \newcommand{\experimentSection}[1]{%
> \stepcounter{experiment}
> \section{Experiment \Roman{experiment}. #1}%
>  }

Yes, the correct section label is generated by latex. And, I've modified the 
LyX Experiment style to show me something workable too ("\theexperimentCounter" 
below just gives me "??" in the document).

Style Experiment
CopyStyle Section
LatexName experimentSection
LabelType Counter
LabelString   "\thesection  Experiment \theexperimentCounter."
LabelCounter  section
Font
Shape   Italic
SizeLarge
EndFont
Preamble
\newcommand{\experimentSection}[1]{%
\stepcounter{experiment}
\section{\textit{Experiment \Roman{experiment}. #1}}%
 }
EndPreamble
End

Now, I need a way to create a label in LyX that refers to value of the 
"experiment" counter. This way, I can refer to the different experiments in 
text by label (and page, etc).

Thanks Guenter for your help so far. I hope you have a solution for this 
question too.

Mateo.