Souci biber avec newrefcontext

Bonjour

pourquoi newrefcontext fonctionne avec le style alphabetic et pas avec
authoryear?

Ci joint un ECM (avec le .bib à la fin).

Si vous remplacez le style alphabetic par authoryear, vous verrez que ça
ne fonctionne plus.

La doc de biblatex n’étant pas très claire, je fais appel à vos compétences.
Bien cordialement
Eric

\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{csquotes,nameref}
\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
% alphabetic fonctionne, numeric aussi

\addbibresource{somme3bib.bib}
\begin{document}
\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={Ref prim.:}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Fichier somme3bib:

@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

Ça a fonctionné chez moi, à la condition préalable de supprimer tous les fichiers auxiliaires (log, bbl, bcp,…).

Le 22 janv. 2025 à 20:03, Eric Guichard xyz@xyz.tld a écrit :

Bonjour

pourquoi newrefcontext fonctionne avec le style alphabetic et pas avec authoryear?

Ci joint un ECM (avec le .bib à la fin).

Si vous remplacez le style alphabetic par authoryear, vous verrez que ça ne fonctionne plus.

La doc de biblatex n’étant pas très claire, je fais appel à vos compétences.
Bien cordialement
Eric

\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm, top=2cm, bottom=3cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{csquotes,nameref}
\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
% alphabetic fonctionne, numeric aussi

\addbibresource{somme3bib.bib}
\begin{document}
\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={Ref prim.:}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses contemporains]

\newrefcontext[labelprefix={R-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Fichier somme3bib:

@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

Voici un premier jet de solution. C’est vite fait et pas complètement testé.


\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}
\end{filecontents*}

\usepackage{csquotes,nameref}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\defbibenvironment{bibliography}
{\list
{\printtext{(\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate})\space}}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\begin{document}

\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Le mer. 22 janv. 2025 à 20:03, Eric Guichard xyz@xyz.tld a
écrit :

Bonjour

pourquoi newrefcontext fonctionne avec le style alphabetic et pas avec
authoryear?

Ci joint un ECM (avec le .bib à la fin).

Si vous remplacez le style alphabetic par authoryear, vous verrez que ça
ne fonctionne plus.

La doc de biblatex n’étant pas très claire, je fais appel à vos
compétences.
Bien cordialement
Eric

\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}

\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{csquotes,nameref}
\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
% alphabetic fonctionne, numeric aussi

\addbibresource{somme3bib.bib}
\begin{document}
\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={Ref prim.:}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Fichier somme3bib:

@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

Le 22/01/2025 à 20:03, Eric Guichard a écrit :

pourquoi newrefcontext fonctionne avec le style alphabetic et pas avec
authoryear?

Une version un peu plus complète qui fonctionne avec ou sans hyperref:


\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

@book{Test,
title=“{Un test}”,
editor=“Test, Louis”, year=“1950”,
publisher=“Un éditeur”, keywords=“20e”,
shorthand=“TestShorthand 1950”,
}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\usepackage{csquotes,nameref}
%\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\newbibmacro*{cite:labeldate+extradate:noref}{%
\iffieldundef{labelyear}%
{}%
{\printtext{\printlabeldateextra}}%
}

\newbibmacro*{cite:shorthand:noref}{%
\printtext{\printfield{shorthand}}}

\newbibmacro*{ref:label-with-prefix}{%
\printtext[parens]{%
\iffieldundef{shorthand}%
{%
\printfield{labelprefix}%
\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate:noref}}
{\usebibmacro{cite:shorthand:noref}}%
}
}

\defbibenvironment{bibliography}
{\list
{\usebibmacro{ref:label-with-prefix}\space}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\begin{document}

\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

Quelques citations: \textcite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}


Cordialement,

 Paul Gaborit

Bonsoir et mille mercis

Ca semble fonctionner magnifiquement.
Je regarde plus en détail demain et j’essaie de comprendre, mais je
crois que ça fait exactement ce que je désirais.
Encore merci
Eric

Le 23/01/2025 à 13:37, Paul Gaborit a écrit :

\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}
\end{filecontents*}

\usepackage{csquotes,nameref}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\defbibenvironment{bibliography}
{\list
{\printtext{(\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate})\space}}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\begin{document}

\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Bonjour et merci.

  1. J’ai compris l’usage et l’intérêt d’hyperref (dans votre version +
    complète).

  2. J’ai réussi à remplacer \addbibresource{\jobname.bib} par
    \addbibresource{somme3bib.bib} (svp, ne vous moquez pas, sourires)

  3. Dans votre première version, j’ai réussi à intégrer des crochets à la
    place des parenthèses:
    \begin{document}
    \DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}

Mais cette modification n’est pas transmise dans la biblio finale:
[B-Bernoulli 1692… % appel ok

Mais:
(B-Bernoulli 1692) Bernoulli, Johann (1692). « Lettre à Varignon »…

  1. Cette modification ne fonctionne pas avec votre version plus complète:
    ! Undefined control sequence.
    l.112 \DeclareOuterCiteDelims

{parencite}{\bibopenbracket}{\bibclosebracket} …

Si vous avez les moyens d’éclairer un peu plus ma lanterne…

Merci d’avance
Eric

Le 23/01/2025 à 22:54, Paul Gaborit a écrit :

Le 22/01/2025 à 20:03, Eric Guichard a écrit :

pourquoi newrefcontext fonctionne avec le style alphabetic et pas avec
authoryear?

Une version un peu plus complète qui fonctionne avec ou sans hyperref:


\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

@book{Test,
title=“{Un test}”,
editor=“Test, Louis”, year=“1950”,
publisher=“Un éditeur”, keywords=“20e”,
shorthand=“TestShorthand 1950”,
}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\usepackage{csquotes,nameref}
%\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\newbibmacro*{cite:labeldate+extradate:noref}{%
\iffieldundef{labelyear}%
{}%
{\printtext{\printlabeldateextra}}%
}

\newbibmacro*{cite:shorthand:noref}{%
\printtext{\printfield{shorthand}}}

\newbibmacro*{ref:label-with-prefix}{%
\printtext[parens]{%
\iffieldundef{shorthand}%
{%
\printfield{labelprefix}%
\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate:noref}}
{\usebibmacro{cite:shorthand:noref}}%
}
}

\defbibenvironment{bibliography}
{\list
{\usebibmacro{ref:label-with-prefix}\space}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\begin{document}

\thispagestyle{empty}

Quelques citations: \parencite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

Quelques citations: \textcite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}


Cordialement,

Le 26/01/2025 à 12:18, Eric Guichard a écrit :

  1. Dans votre première version, j’ai réussi à intégrer des crochets à la
    place des parenthèses:
    […]
    Mais cette modification n’est pas transmise dans la biblio finale:
    […]
  2. Cette modification ne fonctionne pas avec votre version plus complète:

Il me semble que vous n’aviez pas indiqué ce besoin de remplacement des
parenthèses par des crochets dans votre demande initiale.

Ci-dessous vous trouverez une version qui semble marcher comme vous le
voulez… au moins pour les exemples donnés. Mais je ne garantis pas que
ça marchera correctement pour tous les usages de ‘biblatex’: je n’ai pas
testé l’ajout de notes, les citations en note de bas de page, les
références complètes dans le texte, etc.

En fait, il semblerait utile de définir carrément un nouveau style
complet de citation pour répondre parfaitement à votre besoin.


\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

@book{Test,
title=“{Un test}”,
editor=“Test, Louis”, year=“1950”,
publisher=“Un éditeur”, keywords=“20e”,
shorthand=“R2-TestShorthand 1950”,
}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\usepackage{csquotes,nameref}
%\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

%\DeclareFieldFormat{brackets}{\mkbibparens[#1]}

\newbibmacro*{cite:labeldate+extradate:noref}{%
\iffieldundef{labelyear}%
{}%
{\printtext{\printlabeldateextra}}%
}

\newbibmacro*{cite:shorthand:noref}{%
\printtext{\printfield{shorthand}}}

\newbibmacro*{ref:label-with-prefix}{%
\printtext[brackets]{%
\iffieldundef{shorthand}%
{%
\printfield{labelprefix}%
\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate:noref}}
{\usebibmacro{cite:shorthand:noref}}%
}
}

\defbibenvironment{bibliography}
{\list
{\usebibmacro{ref:label-with-prefix}\space}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\begin{document}
\thispagestyle{empty}

Quelques citations hors texte \parencite{BerJ24sept92, Bougain,
Wolff1716, Appel, Test}.

Quelques citations: \textcite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Cordialement,

 Paul Gaborit

Un grand MERCI!
Bien cordialement
Eric

Le 27/01/2025 à 08:12, Paul Gaborit a écrit :

Le 26/01/2025 à 12:18, Eric Guichard a écrit :

  1. Dans votre première version, j’ai réussi à intégrer des crochets à
    la place des parenthèses:
    […]
    Mais cette modification n’est pas transmise dans la biblio finale:
    […]
  2. Cette modification ne fonctionne pas avec votre version plus complète:

Il me semble que vous n’aviez pas indiqué ce besoin de remplacement des
parenthèses par des crochets dans votre demande initiale.

Ci-dessous vous trouverez une version qui semble marcher comme vous le
voulez… au moins pour les exemples donnés. Mais je ne garantis pas que
ça marchera correctement pour tous les usages de ‘biblatex’: je n’ai pas
testé l’ajout de notes, les citations en note de bas de page, les
références complètes dans le texte, etc.

En fait, il semblerait utile de définir carrément un nouveau style
complet de citation pour répondre parfaitement à votre besoin.


\documentclass{article}
\usepackage[paperwidth =170mm, paperheight= 260mm,left=2cm, right=2cm,
top=2cm, bottom=3cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}

\begin{filecontents*}[force]{\jobname.bib}
@article{BerJ24sept92,
author = {Bernoulli, Johann},
title={{Lettre à Varignon}}, journal={Les Annales imaginaires},
volume=“2”, year=“1692”, keywords=“Ber” }

@book{Bougain,
author=“de Bougainville, Louis Antoine”,
title=“{Traité de calcul intégral, pour servir\ldots}”,
address=“Paris”, publisher=“Guérin et Delatour”,
year=“1754”, keywords=“18esiecle”}

@book{Wolff1716, author=“Wolff, Christian”,
title=“Mathematisches lexicon”, address=“Leipzig”,
year=“1716”, publisher=“Anonyme”,
keywords=“18esiecle” }

@book{Appel,
title=“{The Scientific Revolution}”,
editor=“Appel, Wilbur”, year=“1999”,
publisher=“Routledge”, keywords=“20e”}

@book{Test,
title=“{Un test}”,
editor=“Test, Louis”, year=“1950”,
publisher=“Un éditeur”, keywords=“20e”,
shorthand=“R2-TestShorthand 1950”,
}
\end{filecontents*}

\usepackage[colorlinks]{hyperref}

\usepackage{csquotes,nameref}
%\usepackage[style=alphabetic,defernumbers,backend=biber]{biblatex}
\usepackage[style=authoryear,defernumbers,backend=biber]{biblatex}

\addbibresource{\jobname.bib}

%\DeclareFieldFormat{brackets}{\mkbibparens[#1]}

\newbibmacro*{cite:labeldate+extradate:noref}{%
\iffieldundef{labelyear}%
{}%
{\printtext{\printlabeldateextra}}%
}

\newbibmacro*{cite:shorthand:noref}{%
\printtext{\printfield{shorthand}}}

\newbibmacro*{ref:label-with-prefix}{%
\printtext[brackets]{%
\iffieldundef{shorthand}%
{%
\printfield{labelprefix}%
\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}
\usebibmacro{cite:labeldate+extradate:noref}}
{\usebibmacro{cite:shorthand:noref}}%
}
}

\defbibenvironment{bibliography}
{\list
{\usebibmacro{ref:label-with-prefix}\space}
{\setlength{\leftmargin}{1cm}%
\setlength{\labelwidth}{0pt}%
\setlength{\labelsep}{0pt}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}

\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%q
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}%
}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\usebibmacro{cite:label}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}
{\printfield{labelprefix}\printnames{labelname}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenparen}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\DeclareCiteCommand{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\begin{document}
\thispagestyle{empty}

Quelques citations hors texte \parencite{BerJ24sept92, Bougain,
Wolff1716, Appel, Test}.

Quelques citations: \textcite{BerJ24sept92, Bougain, Wolff1716, Appel,
Test}.

\newrefcontext[labelprefix={B-}]
\printbibliography[heading=subbibliography,keyword=Ber,title=Bernoulli]

\newrefcontext[labelprefix={R1-}]
\printbibliography[heading=subbibliography,keyword=18esiecle,title=Ses
contemporains]

\newrefcontext[labelprefix={R2-}]
\printbibliography[heading=subbibliography,keyword=20e,title=Autres]
\end{document}

Cordialement,