This looks to be more a LaTeX issue than a layout issue. Instead of \addtocounter{exemplo}{1}
use \refstepcounter{exemplo} The latter both steps the counter and makes it the target for cross-references. Otherwise, the target remains whatever it was, probably section, which is why you're seeing the "1". Richard Ramon Flores wrote: > Hi: > > I have written a layout that is similar to book, but with a new environment, > called exemplo (example in English). > > This environment has a "LabelType" of type "counter", and the counter works > nicely almost always, both in LyX screen as in output. I.e. each > new "exemplo" is numbered taking into account the previous "exemplos" and the > chapter. > > But it fails when making a cross-reference of one "exemplo". In this case the > exemplo counter is ignored, and the reference is always "1". > > Making layouts is not a easy thing, and after some days struggling with them > I > am exhausted. So I would be very grateful if somebody explain what goes wrong > with my environment. > > Thanks > Ramon > > > The layout is the following > > > ==================================== > livro.layout > > #% Do not delete the line below; configure depends on this > # \DeclareLaTeXClass[book]{livro} > > Format 2 > Input stdclass.inc > Input numreport.inc > > Sides 2 > PageStyle Headings > > NoStyle Abstract > > Counter > Name exemplo > Within chapter > End > > Style Exemplo > Margin First_Dynamic > LatexType Environment > LatexName exemplo > LabelSep xx > ParIndent MMM > ParSkip indent > ItemSep 0.2 > TopSep 0.5 > BottomSep 0.5 > ParSep 0.3 > Align Block > AlignPossible block, left, center, right > LabelType Counter > LabelCounter exemplo > LabelString "Exemplo \arabic{chapter}.\arabic{exemplo}." > LeftMargin MM > RightMargin MM > > Font > Family Sans > Shape Upright > Series Medium > Size Small > EndFont > > LabelFont > Family Sans > Shape Upright > Series Bold > Size Small > EndFont > > Preamble > \newcounter{exemplo} > \setcounter{exemplo}{0} > \newenvironment{exemplo} > { > \begin{list}{} > { > \setlength{\leftmargin}{5mm} > \setlength{\rightmargin}{\leftmargin} > \setlength{\parindent}{0mm} > \upshape > \sffamily > \small > } > \item[] > \addtocounter{exemplo}{1} > \textbf{Exemplo \thechapter .\theexemplo} > } > { > \par > \end{list} > } > EndPreamble > End > > Style Bibliography > TopSep 4 > LabelString "Bibliography" > LabelFont > Series Bold > Size Huge > EndFont > End > -- ================================================================== Richard G Heck, Jr Professor of Philosophy Brown University http://bobjweil.com/heck/ ================================================================== Get my public key from http://sks.keyserver.penguin.de Hash: 0x1DE91F1E66FFBDEC Learn how to sign your email using Thunderbird and GnuPG at: http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto