%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/985914/root/data/old/usr/share/texlive/texmf-dist/doc/latex/fancyref/
Upload File :
Create Path :
Current File : //proc/985914/root/data/old/usr/share/texlive/texmf-dist/doc/latex/fancyref/freftest.tex

%%
%% This is file `freftest.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fancyref.dtx  (with options: `testfile')
%% 
%% LaTeX package for fancy cross-referencing.
%% 
%% Copyright (C) 1999  Axel Reichert
%% See the files README and COPYING.
%% 
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\documentclass[12pt,a4paper]{ltxdoc}
\usepackage{fancyref}
\fancyrefaddcaptions{english}{%
  \newcommand*{\Frefthmname}{Theorem}%
  \newcommand*{\frefthmname}{\MakeLowercase{\Frefthmname}}%
}%
\newcommand*{\booktitle}[1]{``#1''}
\newcommand*{\format}[1]{\texttt{#1}}
\newcommand*{\labelname}[1]{\texttt{#1}}
\newcommand*{\option}[1]{\texttt{#1}}
\newcommand*{\package}[1]{\texttt{#1}}
\newcommand*{\person}[1]{\textsc{#1}}
\newcommand*{\prefix}[1]{\texttt{#1}}
\newcommand*{\stringdef}[1]{``#1''}
\newtheorem{theorem}{Theorem}
\begin{document}
Let us start with a famous equation:
\begin{equation}
  \label{eq:pythagoras}
  a^2 + b^2 = c^2
\end{equation}
\Fref{eq:pythagoras} has been proven by \person{Pythagoras}.  And this
cross-reference was made with |\Fref{eq:pythagoras}|.  Note that I
really wrote:
\begin{verbatim}
   \Fref{eq:pythagoras} has ...
\end{verbatim}
I did not use:
\begin{verbatim}
   Equation~(\Fref{eq:pythagoras}) has ...
\end{verbatim}

See the next page for further features of the \package{fancyref}
package, I need this page break for demonstration purposes.

\clearpage
The cross-reference works also in the middle of a sentence:
\person{Pythagoras} has proven \fref{eq:pythagoras}.  And this
cross-reference was made with |\fref{eq:pythagoras}|.  You can see the
fancy output from the \package{varioref} package.

Oh, you do not like this package and want normal \cmd{\ref} output
instead?  No problem, just redefine the default format:
\renewcommand*{\fancyrefdefaultformat}{plain}
\begin{verbatim}
   \renewcommand*{\fancyrefdefaultformat}{plain}
\end{verbatim}
Now the cross-reference looks like this:  \Fref{eq:pythagoras}.  There
is also a package option called \option{plain} for this purpose.

Oh, you do not like \stringdef{Equation} and want \stringdef{Eq.}
instead?  No problem, just redefine the string:
\renewcommand*{\Frefeqname}{Eq.}
\begin{verbatim}
   \renewcommand*{\Frefeqname}{Eq.}
\end{verbatim}
\Fref{eq:pythagoras} and \fref{eq:pythagoras} will be the result,
respectively.  Note that there is no need to redefine
\cmd{\frefeqname} to \stringdef{eq.}.  The \package{fancyref} package
will do this automatically for you.  But of course you can use
\stringdef{eqn.} instead, if you really want to.

Oh, you are not using the colon as a delimitor but rather the dash?  No
problem, just redefine the character:
\renewcommand*{\fancyrefargdelim}{-}
\begin{verbatim}
   \renewcommand*{\fancyrefargdelim}{-}
\end{verbatim}
The new test equation with label \labelname{eq-trivial} will be:
\begin{equation}
  \label{eq-trivial}
  a = a
\end{equation}
The cross-reference |\fref{eq-trivial}| will give \fref{eq-trivial} as
output, as expected.

All that stuff may be nice, but you are using \prefix{eqn} instead of
\prefix{eq}?  No problem, just redefine the prefix:
\fancyrefchangeprefix{\fancyrefeqlabelprefix}{eqn}
\begin{verbatim}
   \fancyrefchangeprefix{\fancyrefeqlabelprefix}{eqn}
\end{verbatim}
We need a new, fantastic test equation with label
\labelname{eqn-fantastic}:
\begin{equation}
  \label{eqn-fantastic}
  b = b
\end{equation}
The cross-reference |\fref{eqn-fantastic}| will give
\fref{eqn-fantastic} as output, as expected.

Maybe the spacing between \stringdef{eq.} and ``3'' is too generous,
let us tighten things a bit, with
\renewcommand*{\fancyrefdefaultspacing}{\fancyreftightspacing}
\begin{verbatim}
   \renewcommand*{\fancyrefdefaultspacing}{%
     \fancyreftightspacing
   }
\end{verbatim}
the spacing looks like \fref{eqn-fantastic}.  If you think this is
better, just use the \option{tight} option of this package.
\fancyrefchangeprefix{\fancyrefeqlabelprefix}{eq}

Perhaps you want parentheses around the cross-reference?  No problem,
just redefine the appropriate hook:
\renewcommand*{\fancyrefhook}[1]{(#1)}
\begin{verbatim}
   \renewcommand*{\fancyrefhook}[1]{(#1)}
\end{verbatim}
The result from |\fref{eq-trivial}| is \fref{eq-trivial}.  In fact
this could have been obtained easier, as I provided an package option
just for this purpose:
\begin{verbatim}
   \usepackage[paren]{fancyref}
\end{verbatim}

Now let us try something really cool.  What about introducing a new
type of objects, e.\,g.\ theorems, with \prefix{thm} prefixed, new
strings like \stringdef{Theorem} added and the cross-reference in huge
italics?  Also, as you have read in that bargain textbook on
typography (\booktitle{cAN U rEaD It} by \person{John Badmountain}),
cross-references to theorems should be typeset as footnotes.  No
problem:  First, we need a new prefix:
\newcommand*{\fancyrefthmlabelprefix}{thm}
\begin{verbatim}
   \newcommand*{\fancyrefthmlabelprefix}{thm}
\end{verbatim}
Then we declare a new \package{fancyref} format called \format{foot}:
\frefformat{foot}{\fancyrefthmlabelprefix}{%
  \unskip\footnote{%
    \huge\itshape\Frefthmname\fancyrefdefaultspacing#1#3%
  }%
}
\Frefformat{foot}{\fancyrefthmlabelprefix}{%
  \unskip\footnote{%
    \huge\itshape\Frefthmname\fancyrefdefaultspacing#1#3%
  }%
}
\begin{verbatim}
   \frefformat{foot}{\fancyrefthmlabelprefix}{%
     \unskip\footnote{%
       \huge\itshape\Frefthmname\fancyrefdefaultspacing#1#3%
     }%
   }
   \Frefformat{foot}{\fancyrefthmlabelprefix}{%
     \unskip\footnote{%
       \huge\itshape\Frefthmname\fancyrefdefaultspacing#1#3%
     }%
   }
\end{verbatim}
The strings have to be setup in the preamble of the document, I did
this already, because I knew it would be necessary.  The code I used
was:
\begin{verbatim}
   \fancyrefaddcaptions{english}{%
     \newcommand*{\Frefthmname}{Theorem}%
     \newcommand*{\frefthmname}{%
       \MakeLowercase{\Frefthmname}%
     }%
   }%
\end{verbatim}
And finally this is the test theorem:
\begin{theorem}[Murphy]
  \label{thm-murphy}
  If something \emph{can} go wrong, it \emph{will} go wrong.
\end{theorem}
Now let us try it.  |\Fref[foot]{thm-murphy}| comes out
as \Fref[foot]{thm-murphy}.  Oops, the hook is still at work, I will
just reset it to its default value:
\renewcommand*{\fancyrefhook}[1]{#1}%
\begin{verbatim}
   \renewcommand*{\fancyrefhook}[1]{#1}
\end{verbatim}
And now?  \Fref[foot]{thm-murphy} Gotcha!
\end{document}
\endinput
%%
%% End of file `freftest.tex'.

Zerion Mini Shell 1.0