Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Again about the @set label for authoryear style #681

Closed
hushidong opened this issue Jan 12, 2018 · 13 comments
Closed

Again about the @set label for authoryear style #681

hushidong opened this issue Jan 12, 2018 · 13 comments

Comments

@hushidong
Copy link

hushidong commented Jan 12, 2018

Again about the @set label for authoryear style

The @set with a label from the first member is really usable in real world.

For example, used in multi-language bibliography for author year style.
sometimes we need to list bib info in different language for the same work, like this:

biblatex v3.7:

a

biblatex v3.10

b

the src code is:

\documentclass[twoside]{article}
\usepackage{ctex}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage[backend=biber,style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{egbib.bib}
@Book{易仕和2013--,
  Title                    = {超声速和高超声速喷管设计},
  Address                  = {北京},
  Author                   = {易仕和 and 赵玉新 and 何霖 and 张敏莉},
  Publisher                = {国防工业出版社},
  Year                     = {2013}
}

@Book{Yi2013--,
  Title                    = {Supersonic and hypersonic nozzle design},
  Address                  = {BeiJing},
  Author                   = {Yi, S H and Zhao, Y X and He, L and Zhang, M L},
  Publisher                = {National Defense Industry Press},
  Year                     = {2013}
}
\end{filecontents}
\addbibresource[location=local]{egbib.bib}

\begin{document}

\defbibentryset{bilangyi2013}{易仕和2013--,Yi2013--}
double language citation\cite{bilangyi2013}

\printbibliography
\end{document} 

I found this problem until biblatex updated yesterday, and it works well with biblatex v3.7.

In issue #619: @set still gives odd results for authoryear, authortitle, and verbose styles .

moewew said the behaviour of biblatex 3.7 would cause the problem that a @set cannot be distinguished from the first menber in citation, and the best way for biblatex >3.7 is add a label manually, but its a problem for \defbibentryset.

so i'd like to ask is there a solution via biber sourcemap as plk said.
the goal of sourcemap is to create a label for @set with the first member's label or other user dynamically defined label via a cmd like \defbibentryset or a new cmd related to \defbibentryset.

@moewew
Copy link
Collaborator

moewew commented Jan 12, 2018

Thank you for reporting this.

I think in this instance the related functionality would give better results than a @set.

\documentclass[twoside]{article}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage[backend=biber,style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{orig--,
  Title                    = {Test},
  Address                  = {Address},
  Author                   = {A and B and C},
  Publisher                = {Publisher},
  Year                     = {2013},
  related                  = {Yi2013--},
}
@Book{Yi2013--,
  Title                    = {Supersonic and hypersonic nozzle design},
  Address                  = {BeiJing},
  Author                   = {Yi, S H and Zhao, Y X and He, L and Zhang, M L},
  Publisher                = {National Defense Industry Press},
  Year                     = {2013}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
double language citation\cite{orig--}

\printbibliography
\end{document} 

(I didn't have the necessary fonts installed, so I dumbed-down the example)

@hushidong
Copy link
Author

it is a good method,but there is another problem。

how can I define the relation dynamically?

I donot want to change the bib file statically (where entrys are not related),because when there is no demand of double-languge bibliography, I have to change it again.

@moewew
Copy link
Collaborator

moewew commented Jan 12, 2018

You could use sourcemapping to do this dynamically

\documentclass[twoside]{article}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage[backend=biber,style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{orig--,
  Title                    = {Test},
  Address                  = {Address},
  Author                   = {A and B and C},
  Publisher                = {Publisher},
  Year                     = {2013},
}
@Book{Yi2013--,
  Title                    = {Supersonic and hypersonic nozzle design},
  Address                  = {BeiJing},
  Author                   = {Yi, S H and Zhao, Y X and He, L and Zhang, M L},
  Publisher                = {National Defense Industry Press},
  Year                     = {2013}
}
\end{filecontents}
\addbibresource{\jobname.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=entrykey, match={orig--}, final]
      \step[fieldset=related, fieldvalue={Yi2013--}]
    }
  }
}

\begin{document}
double language citation\cite{orig--}

\printbibliography
\end{document} 

@hushidong
Copy link
Author

oh, right!

there can be mutiple DeclareSourcemap,

thanks a lot !

@moewew
Copy link
Collaborator

moewew commented Jan 12, 2018

Actually, at the moment there can't be multiple \DeclareSourcemaps, so you will have to combine them. But that will change with in the next release (#227).

@hushidong
Copy link
Author

for now mutlitple 'DeclareStyleSourcemap' can be used alternatively?

@moewew
Copy link
Collaborator

moewew commented Jan 12, 2018

I think so, yes.

@hushidong
Copy link
Author

ok,thanks

@moewew
Copy link
Collaborator

moewew commented Jan 25, 2018

Is there anything else we need to do here?

The use case you mention has not really convinced me that it is natural or makes sense to let a @set have the label of its first member, especially since there are better solutions available out of the box.

@hushidong
Copy link
Author

No, thanks !
I have transfered to the 'related' solution you proposed above for biblatex >3.7. It is enough for multiple languages bibliography, even for dynamic defining.

There is one question I want to ask. the code \ifnumgreater{\value{bbx:relatedcount}}{0} I modified in bibmacro*{related} has the origin value 1, in that case the first related entry is not separated with \relateddelim after the main entry, is it a mistake in writing or a special dealing for some intents?

\renewbibmacro*{related}{%
  \ifboolexpr{ test {\iffieldundef{related}} or test {\ifrelatedloop} }
	{}
	{\usebibmacro{begrelated}%
	 \def\bbx@tempa{}%
	 \setcounter{bbx:relatedtotal}{0}%
	 \def\do##1{%
	   \entrydata{##1}{%
		 \ifrelatedloop
		   {}
		   {\stepcounter{bbx:relatedtotal}%
			\gappto{\bbx@tempa}{##1,}}}}%
	 \docsvfield{related}%
	 \restorefield{related}{\bbx@tempa}%
	 \ifnumgreater{\value{bbx:relatedtotal}}{0}
	   {\listcsxadd{bbx:relatedloop}{\strfield{entrykey}}%
		\iffieldundef{clonesourcekey}
		  {}
		  {\listcsxadd{bbx:relatedloop}{\strfield{clonesourcekey}}}%
		\setcounter{bbx:relatedcount}{0}%
		\def\do{%
		  \stepcounter{bbx:relatedcount}%
		  \ifnumgreater{\value{bbx:relatedcount}}{0}%modifed from 1
			{\ifcsundef{relateddelim\strfield{relatedtype}}
			  {\printtext{\relateddelim}}
			  {\printtext{\csuse{relateddelim\strfield{relatedtype}}}}}
			{}}%
		\ifbibmacroundef{related:\strfield{relatedtype}}
		  {\appto{\do}{\usebibmacro{related:default}}}
		  {\appto{\do}{\usebibmacro*{related:\strfield{relatedtype}}}}%
		\iffieldformatundef{related:\strfield{relatedtype}}
		  {\def\bbx@tempa{related}}
		  {\def\bbx@tempa{related:\strfield{relatedtype}}}%
		\iffieldformatundef{relatedstring:\strfield{relatedtype}}
		  {\def\bbx@tempb{relatedstring:default}}
		  {\def\bbx@tempb{relatedstring:\strfield{relatedtype}}}%
		\printtext[\bbx@tempa]{%
		  \usebibmacro{begrelatedloop}%
		  \iffieldundef{relatedstring}
			{\ifboolexpr{
			   test {\ifnumgreater{\value{bbx:relatedtotal}}{1}}
			   and
			   test {\ifbibxstring{\thefield{relatedtype}s}}
			 }
			   {\printtext[\bbx@tempb]{%
				  \bibstring[\mkrelatedstring]{\thefield{relatedtype}s}}}
			   {\iffieldbibstring{relatedtype}
				  {\printtext[\bbx@tempb]{%
					 \bibstring[\mkrelatedstring]{\thefield{relatedtype}}}}
				  {}}}
			{\iffieldbibstring{relatedstring}
			   {\printtext[\bbx@tempb]{%
				  \bibstring[\mkrelatedstring]{\thefield{relatedstring}}}}
			   {\printfield[\bbx@tempb]{relatedstring}}}%
		  \docsvfield{related}%
		  \usebibmacro{endrelatedloop}}}%
	   {}%
	 \usebibmacro{endrelated}}}

@moewew
Copy link
Collaborator

moewew commented Jan 25, 2018

Can you please open a new issue with a full MWE we can run for the relateddelim issue? I.e. an issue that showed the undesired behaviour? I'm not quite sure what you want to do.

@hushidong
Copy link
Author

ok!

@moewew
Copy link
Collaborator

moewew commented Jan 25, 2018

Thank you. I'm closing this for now.

@moewew moewew closed this as completed Jan 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants