Giter Site home page Giter Site logo

jinwen-xu / crefthe Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 2.03 MB

Cross referencing with proper definite articles and declensions

Home Page: https://ctan.org/pkg/crefthe

License: LaTeX Project Public License v1.3c

TeX 100.00%
cleveref cross-referencing latex latex3 cross-reference latex-package

crefthe's Introduction

crefthe — cross referencing with proper definite articles and declensions

"crefthe" is a LaTeX package aimed at helping \cref to handle the definite articles and declensions properly (especially for the phenomenon of article contractions in many European languages, such as French and German).

Package dependencies: cleveref, regexpatch.

Motivation

By default, when using cleveref's \cref to reference theorem-like environments, the names do not contain definite articles. This may be acceptable for English, but certainly not good enough for languages such as French, Italian, Portuguese, Spanish, etc. — in these cases there shall be grammatical errors and would give you a strong feeling that it is machine-generated.

As an example, if we define the French names to be:

\crefname{theorem}{le théorème}{les théorèmes}
\crefname{proposition}{la proposition}{les propositions}

Then when one writes (which means "We can deduce this from ..."):

On peut le déduire de \cref{thm1,thm2,prop3}.

the result would be:

On peut le déduire de les théorèmes 1 et 2 et la proposition 3.

which is wrong, as the correct result should be:

On peut le déduire des théorèmes 1 et 2 et de la proposition 3.

\cref would not be able to handle such cases correctly.

The solution

Thus, it would be better to have a new command \crefthe[<prep>]{<labels>}, and to use it like

\crefthe[de]{thm1,thm2,prop3}

in order to get "des théorèmes 1 et 2 et de la proposition 3".

Usage

Simply load the package with:

\usepackage{crefthe}

"crefthe" uses "cleveref" internally, thus it should usually be placed at the last of your preamble.

With the package option overwrite, you may simply use \cref for \crefthe, and similarly for other commands.

Before everything, you need to define the names, which can be done with \crefthename. Its syntax is similar to \crefname, but now you can specify the definite articles, for example (in French):

\crefthename{theorem}[le]{théorème}[les]{théorèmes}

Then you can use the command \crefthe as follows:

  • \crefthe[<prep>]{<labels>}
    • This will pass the preposition <prep> to the definite articles that follows. Its behavior depends on the current language (for example, in Spanish, <prep> is passed only to the first definite article, while in French it is passed to everyone).
  • \crefthe-[<prep>]{<labels>} and \crefthe+[<prep>]{<labels>}
    • In case the automatic version does not meet your needs, here are two manual ones. The - version passes the preposition <prep> only to the first definite article, while the + version passes <prep> to every definite article.
  • There is also a stared version \crefthe* for generating the same text but without hyperlinks.
  • The name-only relatives are also available: \namecrefthe and \namecrefsthe.
  • \cpagerefthe and \Cpagerefthe are provided as well.

Regarding language with declensions

In German, there are four declensions: nominative (Nominativ), genitive (Genitiv), dative (Dativ) and accusative (Akkusativ). For such situation, we introduce the command \crefthevariantname to specify the referencing name for the correspond environment. Below is an example of usage:

\crefthevariantname{theorem}
  {
    {Satz}{Sätze}
    , Nominativ = [der]{Satz}[die]{Sätze}
    , Genitiv   = [des]{Satzes}[der]{Sätze}
    , Dativ     = [dem]{Satz}[den]{Sätzen}
    , Akkusativ = [den]{Satz}[die]{Sätze}
  }

The first line in the configuration is the default set of names when no variant is specified. It is recommended, though not required.

After this, you may refer to a theorem via

\crefthe[<prep>,variant=<declension>]{<label>}

You may also use the shortcuts (nom., gen., dat. and akk.), such as:

\crefthe[<prep>,Nom]{<label>}     \crefthe[<prep>,Nom.]{<label>}
\crefthe[<prep>,nom]{<label>}     \crefthe[<prep>,nom.]{<label>}

These four are all equivalent and you may choose one to use according to your preference.

For more information, please refer to the documentation.

Acknowledgement

There are so many people I wish to express my gratitude to during the development of this package, including:

  • Patrick Bideault, without whose advice and careful explanation, this package probably would never have been born. Merci !

  • Enrico Gregorio, Phelype Oleinik and Joseph Wright (in alphabetical order). They made valuable suggestions in the early development of this package and even edited some of the code themselves.

  • Jonathan P. Spratte, without whose help the German support would probably take much longer to complete.

License

This work is released under the LaTeX Project Public License, v1.3c or later.

crefthe's People

Contributors

jinwen-xu avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

dbitouze

crefthe's Issues

Patch failed

The following MCE fails to compile because a patch failed (BTW, a more meaningful error message would be welcome 😄)

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{crefthe}
\usepackage{cleveref}

\crefname{theorem}{le théorème}{les théorèmes}
\crefname{proposition}{la proposition}{les propositions}

\crefthename{theorem}[le]{théorème}[les]{théorèmes}
\crefthename{proposition}[la]{proposition}[les]{propositions}

\newtheorem{theorem}{Théorème}
\newtheorem{proposition}{Proposition}

\begin{document}
\begin{theo}\label{thm1}
  Foo
\end{theo}
\begin{theo}\label{thm2}
  Bar
\end{theo}
\begin{proposition}\label{prop3}
  Baz
\end{proposition}

On peut le déduire de \cref{thm1,thm2,prop3}.

On peut le déduire \crefthe[de]{thm1,thm2,prop3}.
\end{document}

Here is my File List

 article.cls    2021/10/04 v1.4n Standard LaTeX document class
  size10.clo    2021/10/04 v1.4n Standard LaTeX file (size option)
 fontenc.sty
   t1lmr.fd    2015/05/01 v1.6.1 Font defs for Latin Modern
   babel.sty    2022/04/30 3.74 The Babel package
  french.ldf    2022/04/18 v3.5n French support from the babel system
scalefnt.sty    
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
 crefthe.sty    2022/04/24 Cross referencing with proper definite articles
l3keys2e.sty    2022-01-12 LaTeX2e option processing using LaTeX3 keys
   expl3.sty    2022-05-04 L3 programming layer (loader) 
l3backend-luatex.def    2022-04-20 L3 backend support: PDF output (LuaTeX)
cleveref.sty    2018/03/27 v0.21.4 Intelligent cross-referencing
regexpatch.sty    2021/03/21 v0.2f Extending etoolbox patching commands
  xparse.sty    2022-01-12 L3 Experimental document command parser
  ts1cmr.fd    2019/12/16 v2.5j Standard LaTeX font definitions
 ***********

Articles with apostrophes

Is there a way to use articles with apostrophes? For instance, in French, I tried using

  \crefthename{equation}[l']{équation}[les]{équations}

in order to use \crefthe with an equation. However, this inserts a space between l' and équation givint l' équationwhile I'd like l'équation. Is there a way to remove it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.