feat(latex): enhance keywords command to update PDF keywords metadata

This commit is contained in:
Rifqi D. Panuluh
2025-10-17 10:48:14 +00:00
parent f561998871
commit 8252f99f01

View File

@@ -28,6 +28,7 @@
\RequirePackage{tocbibind} \RequirePackage{tocbibind}
\RequirePackage{indentfirst} \RequirePackage{indentfirst}
\RequirePackage{float} \RequirePackage{float}
\RequirePackage{atbegshi}
\RequirePackage{amsmath,amsfonts,amssymb} \RequirePackage{amsmath,amsfonts,amssymb}
\RequirePackage[style=apa,% \RequirePackage[style=apa,%
% dateabbrev=false,% when false, don't abbreviate months/year divisions % dateabbrev=false,% when false, don't abbreviate months/year divisions
@@ -466,19 +467,29 @@
\fi% \fi%
\fi% \fi%
\fi% \fi%
} }
\makeatother
\newcommand{\keywords}[1]{% % Wrap your existing \keywords so it:
% \vspace{1em}% % 1) computes \sortedlist
\bigskip % 2) prints it
\noindent% % 3) also updates PDF metadata for XeLaTeX via xdvipdfmx \special
\newcommand{\keywords}[1]{%
\bigskip\noindent
\ifnum\strcmp{\languagename}{malay}=0 \ifnum\strcmp{\languagename}{malay}=0
Kata Kunci: \alphabubblesort{#1}\sortedlist% Kata Kunci: \alphabubblesort{#1}\sortedlist%
\else \else
\textit{Keywords:} \alphabubblesort{#1}\sortedlist% \textit{Keywords: } \alphabubblesort{#1}\sortedlist%
\fi \fi
% -- store for metadata --
\gdef\SortedKeywords{\sortedlist}%
% Sanitize for PDF string (escapes parentheses, makes nice unicode)
\pdfstringdef\kwpdf{\SortedKeywords}%
% For XeLaTeX/xdvipdfmx, override PDF docinfo directly; the last call wins.
\immediate\special{pdf:docinfo << /Keywords (\kwpdf) >>}%
% If you also want hyperrefs internal copy updated (harmless):
\hypersetup{pdfkeywords={\SortedKeywords}}%
} }
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Change the text of the cross-reference links to the Slovene long version. % Change the text of the cross-reference links to the Slovene long version.
@@ -536,20 +547,26 @@
\newcommand{\theuniversity}{\@university} \newcommand{\theuniversity}{\@university}
\newcommand{\theyearofsubmission}{\@yearofsubmission} \newcommand{\theyearofsubmission}{\@yearofsubmission}
\AtBeginDocument{%
\hypersetup{
pdftitle={\@title},
pdfauthor={\@author}
}%
}
% Ensure title/author/date get expanded correctly in hypersetup % Ensure title/author/date get expanded correctly in hypersetup
% \hypersetup{ \hypersetup{
% pdftitle={\@title}, % pdftitle={gfhfdhfd},
% pdfauthor={\@author}, % pdfauthor={\@authorid},
% pdfdate={\@date}, % pdfdate={\@date},
% pdfsubject={Bachelor Thesis}, pdfsubject={Bachelor Thesis},
% pdfkeywords={structural health monitoring, machine learning, stft, vibration, signal}, % pdfkeywords={\@keywordslist},
% pdfpublisher={Universitas Muhammadiyah Yogyakarta}, % pdfpublisher={Universitas Muhammadiyah Yogyakarta},
% pdfcontactemail={rifqi.damar.ft21@mail.umy.ac.id}, % pdfcontactemail={rifqi.damar.ft21@mail.umy.ac.id},
% pdflicenseurl={https://github.com/nuluh/thesis/blob/main/LICENSE}, % pdflicenseurl={https://github.com/nuluh/thesis/blob/main/LICENSE},
% pdflang={id}, pdflang={id},
% pdfcreator={XeLaTeX with hyperref and hyperxmp}, pdfcreator={XeLaTeX with hyperref and hyperxmp},
% pdfproducer={TeX Live 2024}, pdfproducer={TeX Live 2024},
% pdftrapped=False pdftrapped=False
% } }
\makeatother \makeatother
\endinput \endinput