บรรณานุกรม: เน้นการอ้างอิงล่าสุดโดยอัตโนมัติโดยเพิ่มเครื่องหมายดอกจันที่ขอบด้านซ้าย
ฉันกำลังอัปเดตรายการข้อมูลอ้างอิงและฉันต้องการเน้นการอ้างอิงที่เพิ่มเข้ามาตั้งแต่การอัปเดตครั้งล่าสุด ตัวอย่างเช่นฉันต้องการเพิ่มเครื่องหมายดอกจัน (หรือสัญลักษณ์อื่น) ก่อนการอ้างอิง (ควรอยู่ในขอบด้านซ้ายหรืออย่างน้อยก็ที่จุดเริ่มต้นของการอ้างอิง)
อย่างไรก็ตามตรงข้ามกับคำถามมากมายที่ถามไปแล้ว (เช่นเพิ่มเครื่องหมายดอกจันตามคำหลักบางคำ) ฉันต้องการเพิ่มเครื่องหมายดอกจันโดยอัตโนมัติตามวันที่ที่ระบุ
.bib
ไฟล์ถูกสร้างขึ้นด้วย JabRef เพื่อให้แต่ละอ้างอิงมีช่อง "ประทับเวลาที่" (รูปแบบ: YYYY-MM-DD หรือ yyyy.mm.dd) ช่องนี้สามารถใช้เพิ่มเครื่องหมายดอกจัน
MWE:
\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Rabelais1532,
author = {Rabelais, Fran\c{c}ois},
date = {1532},
title = {Pantagruel},
timestamp = {2018-07-01},
}
@book{Hugo1862,
author = {Hugo, Victor},
date = {1862},
title = {Les Mis\'{e}rables},
timestamp = {2019-07-01},
}
@book{Hugo1831,
author = {Hugo, Victor},
date = {1831},
title = {Notre-Dame de Paris},
timestamp = {2020.01.31},
}
@book{Zola1885,
author = {Zola, \'{E}mile},
date = {1885},
title = {Germinal},
timestamp = {2020-02-01},
}
@book{Balzac1831,
author = {de Balzac, Honor\'{e}},
date = {1831},
title = {The Skin of Sorrow},
timestamp = {2020-06-15},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
ฉันได้พยายามปรับเปลี่ยนโค้ดต่อไปนี้ที่ให้ไว้ในโพสต์นี้แต่ไม่ประสบความสำเร็จ:
\renewbibmacro*{begentry}{%
\iftimestamp{<thechoosendate>}{%
\makebox[0pt][r]{\textasteriskcentered\addspace}%
}{}%
}
ตัวอย่างเช่นฉันต้องการไฮไลต์การอ้างอิงที่เพิ่มเข้ามาตั้งแต่วันที่ 31 มกราคม 2020 (เวลาประทับ> = 2020-01-31)
บางทีเราอาจใช้แพ็คเกจdatetime2
และคำสั่ง\DTMsavedate{lastupdatedate}{2020-01-31}
และ\DTMusedate{lastupdatedate}
เพิ่มประสิทธิภาพการอัปเดตที่กำลังจะมาถึง
- ฉันจะรับข้อมูลอ้างอิงล่าสุดทั้งหมดที่ระบุด้วยเครื่องหมายดอกจันได้อย่างไร?
- ควรอ่านเอกสารใดเพื่อเรียนรู้วิธีการสร้างโปรแกรมประเภทนี้
คำตอบ
ฉันคิดว่ามีหลายวิธีที่ดีในการจัดการกับเรื่องนี้
ขั้นตอนแรกไม่ว่าในกรณีใด ๆ คือการตรวจสอบให้แน่ใจว่าข้อมูลการประทับเวลาเข้าสู่ Biber ในโมเดลข้อมูลมาตรฐานไม่มีฟิลด์ดังกล่าวtimestamp
ดังนั้นฟิลด์จึงถูกละเว้น มีอย่างน้อยสองวิธีในการรับข้อมูลการประทับเวลาไปที่biblatex
:
- ประกาศโมเดลข้อมูลใหม่พร้อม
timestamp
ฟิลด์ - ทำการแมป
timestamp
ไปยังฟิลด์ที่รู้จัก (ตัวอย่างเช่นฟิลด์ขูด 'usera')
ในสิ่งต่อไปนี้เราจะใช้การผสมผสานของสองแนวทาง เราจะประกาศฟิลด์วันที่ใหม่timestampdate
และจะแมปtimestamp
ฟิลด์นั้นด้วยซอร์สแมป Biber (ด้วยเหตุผลทางเทคนิคฟิลด์วันที่ทั้งหมดbiblatex
จะต้องลงท้ายด้วย...date
ดังนั้นจึงtimestampdate
ดูเหมือนเป็นทางเลือกที่ดี) ฉันเลือกเส้นทางที่ซับซ้อนกว่านี้เพราะเราสามารถให้ Biber แยกวิเคราะห์ฟิลด์เป็นวันที่และปีที่กลับเดือนและวันแยกกันได้ นอกจากนี้เราสามารถใช้ขั้นตอนนี้จะปรับรูปแบบวันที่จากไปYYYY.MM.DD
YYYY-MM-DD
มันจะเป็นไปได้อย่างสมบูรณ์แบบที่จะผ่านไปtimestamp
ตามที่เป็นอยู่ไม่ใช่ผ่าน...date
สนาม แต่คุณจะต้องแยกวิเคราะห์วันที่ในฝั่ง LaTeX (ซึ่งไม่ควรยุ่งยากเกินไป)
ด้วยวันที่ที่ผ่านไปbiblatex
เราจำเป็นต้องตรวจสอบว่าเรามีอายุไม่เกินวันที่ที่กำหนดหรือไม่ ซึ่งสามารถตรวจสอบได้โดยดูวันที่ส่วนปีเดือนและวันทีละส่วน สำหรับฟิลด์วันของเราtimestampdate
ปีจะอยู่ในtimestampyear
เดือนในtimestampmonth
ฯลฯ \thefield
เราสามารถเข้าถึงเขตข้อมูลดิบกับ
\documentclass{article}
\begin{filecontents}{timestampdate.dbx}
\ProvidesFile{timestampdate.dbx}[2020/08/19 timestampdate for biblatex]
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
timestampdate,
}
\DeclareDatamodelEntryfields{
timestampday,
timestampendday,
timestampendhour,
timestampendminute,
timestampendmonth,
timestampendsecond,
timestampendtimezone,
timestampendyear,
timestamphour,
timestampminute,
timestampmonth,
timestampsecond,
timestamptimezone,
timestampyear,
}
\end{filecontents}
\usepackage[style=authoryear, backend=biber, datamodel=timestampdate]{biblatex}
\DeclareSourcemap{
\maps{
\map{
% map timestamp to date field timestampdate
\step[fieldsource=timestamp, fieldtarget=timestampdate]
% now convert '.' to '-'
\step[fieldsource=timestampdate, match=\regexp{\.}, replace=\regexp{-}]
% we should now have YYYY-MM-DD format
}
}
}
\makeatletter
% {<datetype prefix>}{<year>}{<month>}{<day>}
% checks if the date stored in the field <datetype>
% is at least <year>-<month>-<day>
% ---
% to understand the code below just 'map'
% \@firstoftwo -> true
% \@secondoftwo -> false
\newcommand*{\ifdateatleast}[4]{%
\ifnumgreater{\thefield{#1year}}{#2}
{\@firstoftwo}
{\ifnumequal{\thefield{#1year}}{#2}
{\ifnumgreater{\thefield{#1month}}{#3}
{\@firstoftwo}
{\ifnumequal{\thefield{#1month}}{#3}
{\ifnumless{\thefield{#1day}}{#4}
{\@secondoftwo}
{\@firstoftwo}}
{\@secondoftwo}}}
{\@secondoftwo}}%
}
\makeatother
\renewbibmacro*{begentry}{%
\ifdateatleast{timestamp}{2020}{1}{1}
{\makebox[0pt][r]{\textasteriskcentered\addspace}}
{}%
}
\begin{filecontents}{\jobname.bib}
@book{Rabelais1532,
author = {Rabelais, Fran\c{c}ois},
date = {1532},
title = {Pantagruel},
timestamp = {2018-07-01},
}
@book{Hugo1862,
author = {Hugo, Victor},
date = {1862},
title = {Les Mis\'{e}rables},
timestamp = {2019-07-01},
}
@book{Hugo1831,
author = {Hugo, Victor},
date = {1831},
title = {Notre-Dame de Paris},
timestamp = {2020.01.31},
}
@book{Zola1885,
author = {Zola, \'{E}mile},
date = {1885},
title = {Germinal},
timestamp = {2020-02-01},
}
@book{Balzac1831,
author = {de Balzac, Honor\'{e}},
date = {1831},
title = {The Skin of Sorrow},
timestamp = {2020-06-15},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

พูดตามตรงฉันไม่แน่ใจว่าคุณจะเริ่มอ่านโปรแกรมนี้ได้ที่ไหน จุดที่สำคัญที่สุดที่นี่คือการรับข้อมูลbiblatex
เนื่องจากtimestamp
จะถูกละเว้นโดยค่าเริ่มต้น ( เพิ่มฟิลด์ "tome" ไปยังรายการ biblatexจะแสดงวิธีการบางอย่างเพื่อรับฟิลด์ 'ใหม่' biblatex
) หลังจากนั้นคุณต้อง 'เพียง' ตรวจสอบให้แน่ใจว่าได้แยกวิเคราะห์วันที่และเปรียบเทียบ มีหลายวิธีในการทำเช่นนั้น ฉันเพิ่งบังเอิญเลือกสิ่งที่เกี่ยวข้องกับ Biber และการbiblatex
จัดการวันที่ แต่นี่ไม่ใช่สิ่งที่กำหนด คุณยังสามารถแยกวิเคราะห์ทุกอย่างด้วยตัวเอง (เปรียบเทียบเป็นไปได้ไหมที่จะแยกวิเคราะห์สตริงวันที่ใน LaTeX เพื่อแปลงเป็นรูปแบบวันที่อื่น? )