Un index des sources primaires (1) - commentaires Un index des sources primaires (1) 2012-08-22T21:53:10Z https://geekographie.maieul.net/-20-#comment378 2012-08-22T21:53:10Z <p>Ps : I don't like use keyword to make ≠ between primary source and secondary source. I think the keyword field should be about topics of entry, and not about status of entry.</p> <p>But with biblatex 2.0, I could define new field, more specific than usera</p> Un index des sources primaires (1) 2012-08-22T21:47:07Z https://geekographie.maieul.net/-20-#comment376 2012-08-22T21:47:07Z <p>thank. Maybe you could post on the github ticket, to help author to implemante in standard biblatex<small class="fine d-inline"> </small>?</p> Un index des sources primaires (1) 2012-08-22T20:49:55Z https://geekographie.maieul.net/-20-#comment373 2012-08-22T20:49:55Z <p>Further to our discussion on TexSX, I'm posting a commented example which shows you how you could, if you wished, set about doing something like this without using Python, if you wish.</p> <p>I hope it makes sense with the comments. Please feel free to email me if you would like to (you can find my email address in the documentation for the oscola package on <span class="caps">CTAN</span>). I hope you find it useful.</p> <p>It would of course be nice to have this sort of facility in biblatex<small class="fine d-inline"> </small>; but it's quite hard to arrive at a workable general solution, actually, because there are so many possible use-cases.</p> <div class="precode"><pre class="latex spip_code spip_code_block" dir="ltr" style="text-align:left;"><code>\documentclass[a4paper]{article} \usepackage{filecontents} % I'm not certain how your commands like \incipit work -- so I've guessed. I doubt % it matters. I have however used the keywords field rather than usera to distinguish % between primary and secondary literature \begin{filecontents}{\jobname.bib} @book{pseudoa, author = {{Pseudo-Augustin}}, title = {Sermon \incipit{Fratres carissimi, unum rei documentum} (Caillau \cRM{2}, 27)}, indexsorttitle = {Sermon fratres carissimi, unum rei documentum (Caillau 2, 27)}, pages = {4}, keywords = {primary}, } @book{secondary, author = {Author, A. N.}, title = {A Title}, keywords = {secondary}, date = {2012}, } \end{filecontents} \usepackage[style=verbose, indexing=cite]{biblatex} \addbibresource{\jobname.bib} \usepackage{index} \newindex{sources}{sox}{sod}{Index of Sources} % This is a convenience: we can redefine \sourceindex if % we want to use a differently named index \newcommand{\sourceindex}{sources} % These are dummies to simulate the commands I see in your % bibfile \newcommand{\incipit}[1]{\emph{#1}} \newcommand{\cRM}[1]{#1} % We renew citeindex so that it does nothing unless we're looking % at a primary source, and then indexes either author or namea, depending % on which is set. We then use a newly defined IndexFieldFormat called primarysource % to actually do the work \renewbibmacro*{citeindex}{% \ifciteindex {\ifkeyword{primary} {\ifnameundef{namea} {\indexnames[primarysource]{author}} {\indexnames[primarysource]{namea}}} {}} {}} % This "prepares the ground", depending on whether % there is a postnote or not. We assume there is always % a title. We don't need to check for indexsorttitle o % indextitle, because these will be automatically set for % us the same as title \DeclareIndexNameFormat{primarysource}{% \iffieldundef{postnote} {\usebibmacro{index:source} {#1}% {#3}% {#5}% {#7}% {\thefield{indexsorttitle}}% {\thefield{indextitle}}% {\thefield{pages}}% } {\usebibmacro{index:source} {#1} {#3}% {#5}% {#7}% {\thefield{indexsorttitle}}% {\thefield{indextitle}}% {\thefield{postnote}}}} \makeatletter % And this actually does the work: #1,#2,#3,#4 are different % parts of the name. #5 is the indexsorttitle. #6 is the indextitle. % #7 is the postnote or pages. \newbibmacro*{index:source}[7]{% \begingroup \ifuseprefix {\protected@edef\theindexentry{% \unexpanded{\index}[\sourceindex]{% \ifblank{#3}{}{#3 }% \@firstofone #1% remove spurious braces \ifblank{#4}{}{ #4}% \ifblank{#2}{}{, #2}% \actualoperator \ifblank{#3}{}{\MakeCapital{#3} }% #1% \ifblank{#4}{}{ #4}% \ifblank{#2}{}{, #2}% !#5% \actualoperator #6% !#7}}} {\protected@edef\theindexentry{% \unexpanded{\index}[\sourceindex]{% \@firstofone #1% remove spurious braces \ifblank{#4}{}{ #4}% \ifblank{#2#3}{}{,}% \ifblank{#2}{}{ #2}% \ifblank{#3}{}{ #3}% !#5% \actualoperator #6% !#7}}} \theindexentry \endgroup} \makeatother \begin{document} \cite{pseudoa} \cite[10]{pseudoa} \cite{secondary} \newpage \cite[6]{pseudoa} \printindex[sources] \end{document}</code></pre></div>