formatting cross references in KOMA-Script and a custom float

2010-09-21 Thread Justin Wood
All,
I've asked a few newbie questions about formatting cross references,
explicitly (thread
herehttp://thread.gmane.org/gmane.editors.lyx.general/65678)
and within a thread
(herehttp://thread.gmane.org/gmane.editors.lyx.general/65312)
where Jürgen Spitzmüller helped me define a custom boxfloat inset. After
many (many) hours, I've finally managed to figure out how to do it all,
so... I thought it might be of some small use to report back. A big part of
the problem was me not thinking to say up front that I was using the thesis
template example posted to this list previously, which employs *KOMA-Script
(book)* document class. Another issue which finally let me solve it all was
realising that specifying a different English dialect was breaking the
intended functionality.

My goal was: 1. to get the custom boxfloat cross reference working as for
floats, tables, etc, with the text 'Box' prepended; and 2. change default
behaviour so that section, subsection, subsubsection are all referred to as
'section'.

*Solution*:


   - by default references in this are simply the numbers, and you have to
   do something to them to get the naming we want. Jürgen quite rightly
   suggested the use of

\newrefformat{box}{Box~\negthinspace\ref{#1}}


   - but note that this only works with *Formatted reference* type, as the
  command is specific to \prettyref



   - now the thesis template preamble included these lines to redefine the
   normal \ref command, using the \autoref functionality in {*hyperref*}. *It
   was not working for me.*

\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1
\newlength{\abc}
\settowidth{\abc}{\space}
\addto\extras*english*{
 \renewcommand{\equationautorefname}{\hspace{-\abc}}
 \renewcommand{\sectionautorefname}{sec.\negthinspace}
...
}


   - the most important point here is that the reference type commands are
  configured to be* language specific*, and I had not realised that my
  documents being set to language=British simply didn't match extras*
  english*



   - so by changing \extrasenglish to \extrasbritish, these reference
   formatting commands now work correctly.
   - the last issue was a crossref for the custom boxfloat inset. (*NB: the
   label for any boxfloat must be inserted with the caption for numbering to
   work properly.*) I haven't been able to figure out how to define the
   \autoref version for a custom counter type, so for now all boxes must use
   *Formatted reference* type, which allows this command to take effect:

\newrefformat{box}{\mbox{\hyperref[{#1}]{Box~\ref{#1


   - rather than the format suggested by Jürgen (above), I used \hyperref
  and the {Box } text to be consistent with \autoref — the prepended label
  text is then *part of* the hyperlink. And to my happy surprise, it all
  works!


HTH!

~:Justin Wood:~
PhD candidate, *Energy  Engineering school*, Murdoch
Universityhttp://www.murdoch.edu.au/


formatting cross references in KOMA-Script and a custom float

2010-09-21 Thread Justin Wood
All,
I've asked a few newbie questions about formatting cross references,
explicitly (thread
herehttp://thread.gmane.org/gmane.editors.lyx.general/65678)
and within a thread
(herehttp://thread.gmane.org/gmane.editors.lyx.general/65312)
where Jürgen Spitzmüller helped me define a custom boxfloat inset. After
many (many) hours, I've finally managed to figure out how to do it all,
so... I thought it might be of some small use to report back. A big part of
the problem was me not thinking to say up front that I was using the thesis
template example posted to this list previously, which employs *KOMA-Script
(book)* document class. Another issue which finally let me solve it all was
realising that specifying a different English dialect was breaking the
intended functionality.

My goal was: 1. to get the custom boxfloat cross reference working as for
floats, tables, etc, with the text 'Box' prepended; and 2. change default
behaviour so that section, subsection, subsubsection are all referred to as
'section'.

*Solution*:


   - by default references in this are simply the numbers, and you have to
   do something to them to get the naming we want. Jürgen quite rightly
   suggested the use of

\newrefformat{box}{Box~\negthinspace\ref{#1}}


   - but note that this only works with *Formatted reference* type, as the
  command is specific to \prettyref



   - now the thesis template preamble included these lines to redefine the
   normal \ref command, using the \autoref functionality in {*hyperref*}. *It
   was not working for me.*

\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1
\newlength{\abc}
\settowidth{\abc}{\space}
\addto\extras*english*{
 \renewcommand{\equationautorefname}{\hspace{-\abc}}
 \renewcommand{\sectionautorefname}{sec.\negthinspace}
...
}


   - the most important point here is that the reference type commands are
  configured to be* language specific*, and I had not realised that my
  documents being set to language=British simply didn't match extras*
  english*



   - so by changing \extrasenglish to \extrasbritish, these reference
   formatting commands now work correctly.
   - the last issue was a crossref for the custom boxfloat inset. (*NB: the
   label for any boxfloat must be inserted with the caption for numbering to
   work properly.*) I haven't been able to figure out how to define the
   \autoref version for a custom counter type, so for now all boxes must use
   *Formatted reference* type, which allows this command to take effect:

\newrefformat{box}{\mbox{\hyperref[{#1}]{Box~\ref{#1


   - rather than the format suggested by Jürgen (above), I used \hyperref
  and the {Box } text to be consistent with \autoref — the prepended label
  text is then *part of* the hyperlink. And to my happy surprise, it all
  works!


HTH!

~:Justin Wood:~
PhD candidate, *Energy  Engineering school*, Murdoch
Universityhttp://www.murdoch.edu.au/


formatting cross references in KOMA-Script and a custom float

2010-09-21 Thread Justin Wood
All,
I've asked a few newbie questions about formatting cross references,
explicitly (thread
here)
and within a thread
(here)
where Jürgen Spitzmüller helped me define a custom boxfloat inset. After
many (many) hours, I've finally managed to figure out how to do it all,
so... I thought it might be of some small use to report back. A big part of
the problem was me not thinking to say up front that I was using the thesis
template example posted to this list previously, which employs *KOMA-Script
(book)* document class. Another issue which finally let me solve it all was
realising that specifying a different English dialect was breaking the
intended functionality.

My goal was: 1. to get the custom boxfloat cross reference working as for
floats, tables, etc, with the text 'Box' prepended; and 2. change default
behaviour so that section, subsection, subsubsection are all referred to as
'section'.

*Solution*:


   - by default references in this are simply the numbers, and you have to
   do something to them to get the naming we want. Jürgen quite rightly
   suggested the use of

\newrefformat{box}{Box~\negthinspace\ref{#1}}


   - but note that this only works with *Formatted reference* type, as the
  command is specific to \prettyref



   - now the thesis template preamble included these lines to redefine the
   normal \ref command, using the \autoref functionality in {*hyperref*}. *It
   was not working for me.*

\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1
\newlength{\abc}
\settowidth{\abc}{\space}
\addto\extras*english*{
 \renewcommand{\equationautorefname}{\hspace{-\abc}}
 \renewcommand{\sectionautorefname}{sec.\negthinspace}
...
}


   - the most important point here is that the reference type commands are
  configured to be* language specific*, and I had not realised that my
  documents being set to language=British simply didn't match extras*
  english*



   - so by changing \extrasenglish to \extrasbritish, these reference
   formatting commands now work correctly.
   - the last issue was a crossref for the custom boxfloat inset. (*NB: the
   label for any boxfloat must be inserted with the caption for numbering to
   work properly.*) I haven't been able to figure out how to define the
   \autoref version for a custom counter type, so for now all boxes must use
   *Formatted reference* type, which allows this command to take effect:

\newrefformat{box}{\mbox{\hyperref[{#1}]{Box~\ref{#1


   - rather than the format suggested by Jürgen (above), I used \hyperref
  and the {Box } text to be consistent with \autoref — the prepended label
  text is then *part of* the hyperlink. And to my happy surprise, it all
  works!


HTH!

~:Justin Wood:~
PhD candidate, *Energy & Engineering school*, Murdoch
University