[XeTeX] enumerating quotations
Zdenek Wagner
zdenek.wagner at gmail.com
Tue Apr 3 23:24:37 CEST 2012
2012/4/3 Jacobo Myerston <jmyerston at gmail.com>:
> Well I came with this command that works and looks like I want:
>
>
> \newcounter{myquote}[chapter]
> \renewcommand{\themyquote}{\arabic{myquote}}
> \newcommand{\myquote}[1]{
> \refstepcounter{myquote}
> \begin{quote}\textbf{T. \themyquote} #1\end{quote}}
>
>
>
> Now, I would prefer it to be an environment and not a command. Could
> somebody help me to translate this into environment definition. I
> tried, but I couldn't.
>
It is quite simple but probably you wish that the quotation will
always start as a new paragraph and the paragraph should be closed at
the end of the quotation, thus I put a few more commands althouh they
will often do nothing (but safeguarding is always preferable). The
definition will be:
\renewenvironment{quote}{\ifhmode \par \fi
\refstepcounter{myquote}
\textbf{T. \themyquote}\space\ignorespaces}{\ifhmode \par \fi}
Now you will use it as:
\begin{quote}
Quotation text...
\end{quote}
Magic commands \space\ignorespaces need some explanation. Consider you write
\begin{quote}Some text\end{quote}
What is the difference? In the previous case there is a line end after
\begin{quote} which will be converted to a single space while in the
second case there is no space preceding the word "Some". In the
definition \space inserts just a single space and \ignorespaces
ignores all following spaces. Thus it does not matter how you type
your document, you will always have a single space after the quotation
number.
This definition allows numbering and you can use \label but I would be
lazy to do it this way if a lof of citations need labels. I would
define the environment with one optional parameter which would be the
label. I would assume that the label name will never contain $. The
corrected definition will then be:
\renewenvironment{quote}[1][]{\ifhmode \par \fi
\refstepcounter{myquote}
\ifcat$#1$\else \label{#1}\fi
\textbf{T. \themyquote}\space\ignorespaces}{\ifhmode \par \fi}
If you use the environment as above (without parameter), no label will
be created. If you wish a label, just put it in the square brackets:
\begin{quote}[mylabel]
Some text
\end{quote}
Now it will almost work. The problem is that \ref will give you just
the number of the quotation but it restarts from 1 in each chapter. If
you wish numbers in the form of 2.3, there is one more macro to be
defined. Remember that the macro name contains @, thus you have to put
the definitions into a package of your own, or you have to change the
category by \makeatletter and \makeatother if you put the definition
jut to the preamble of your document. In the latter case it would be:
\makeatletter
\def\p at myquote{\arabic{chapter}.}
\makeatother
Explanation is quite simple. In general, \refstepcounter{CTR} stores
the contents of \p at CTR\theCTR in a special macro that will be used by
\label and then recalled by \ref. As default, all macros of the form
\p at CTR are empty unless they are defined.
> thanks,
>
> On Tue, Apr 3, 2012 at 3:00 AM, Juan Acevedo <juan.acevedo at gmx.net> wrote:
>> Epa Jacobo,
>>
>> You can find a very clear explanation on counters and how to set up new counters in the *2nd edition* of The Latex Companion. You may want to try also the UK TeX FAQ for good pointers: http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes
>>
>> Χαιρε
>>>
>>> ----------------------------------------------------------------------
>>>
>>> Message: 1
>>> Date: Mon, 2 Apr 2012 14:15:38 -0500
>>> From: Jacobo Myerston <jmyerston at gmail.com>
>>> To: Unicode-based TeX for Mac OS X and other platforms <xetex at tug.org>
>>> Subject: [XeTeX] enumerating quotations
>>> Message-ID: <F3709C69-978B-475D-A52C-2CB473ACA9B3 at gmail.com>
>>> Content-Type: text/plain; charset="us-ascii"
>>>
>>> Hi,
>>>
>>> I'm writing a book in which I quote a significant number of ancient texts. I'm using the \quote environment for this as usual. Now, I would like to have a numbered label to refer back to these quotations along the book. So, I would like the \quote environment to behave somehow like \figure so that the quote is auto-numbered and labels located inside \quote get also an automatic number.
>>>
>>> Does anybody how to do this?
>>>
>>> I'm using memoir.
>>
>>
>>
>> --------------------------------------------------
>> Subscriptions, Archive, and List information, etc.:
>> http://tug.org/mailman/listinfo/xetex
>
>
>
> --------------------------------------------------
> Subscriptions, Archive, and List information, etc.:
> http://tug.org/mailman/listinfo/xetex
--
Zdeněk Wagner
http://hroch486.icpf.cas.cz/wagner/
http://icebearsoft.euweb.cz
More information about the XeTeX
mailing list