
패키지 를 사용하여 용어집의 각 단어에 대한 첫 글자를 대문자로 표시하는 방법은 무엇입니까 glossaries-extra
?
나는 우연히 만났다이 스레드하지만 패키지를 사용합니다 glossaries
.
나도 해봤는데 \glsentrytitlecase{<label>}{long}
안되더라
- 용어집을 하이퍼링크로 만들기
- 끝에 있는 괄호 안에 용어집을 포함합니다(예: 아래 MWE의 (ES)).
기본적으로 내가 원하는 것은 비슷 \Gls
하지만 첫 번째 단어 대신 각 단어의 첫 글자를 대문자로 만드는 것입니다.
MWE:
\documentclass[a4paper,12pt]{article}
\usepackage[acronym]{glossaries-extra}
\setabbreviationstyle[acronym]{long}
\newacronym
[
description={Evolutionary Strategies},
longplural={evolutionary strategies}
]
{es}{ES}{evolutionary strategy}
\makeglossaries
\begin{document}
\printglossary[type=acronym,title={List of Acronyms}]
\glsentrytitlecase{es}{long}.
\glspl{es}.
\Glspl{es}.
\glsentrytitlecase{es}{longpl}.
\end{document}
업데이트:
\documentclass[a4paper,12pt]{article}
\usepackage[acronym,automake]{glossaries-extra}
\makeatletter
\newrobustcmd*{\myGls}{\@gls@hyp@opt\@myGls}
\newcommand*{\@myGls}[2][]{%
\new@ifnextchar[{\@myGls@{#1}{#2}}{\@myGls@{#1}{#2}[]}%
}
\def\@myGls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
\let\glsifplural\@secondoftwo
\let\glscapscase\@secondofthree
\def\glscustomtext{%
{%
\ecapitalisewords{\glsentrylong{#2}}#3\space%
\firstacronymfont(\glsentryshort{#2})}%
}
\def\glsinsert{#3}%
\def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
\@gls@link[#1]{#2}{\@glo@text}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
\glspostlinkhook
}
\newrobustcmd*{\myGlspl}{\@gls@hyp@opt\@myGlspl}
\newcommand*{\@myGlspl}[2][]{%
\new@ifnextchar[{\@myGlspl@{#1}{#2}}{\@myGlspl@{#1}{#2}[]}%
}
\def\@myGlspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
\let\glsifplural\@firstoftwo
\let\glscapscase\@secondofthree
\def\glscustomtext{%
{%
\ecapitalisewords{\glsentrylongpl{#2}}#3\space%
\firstacronymfont(\glsentryshortpl{#2})}%
}
\def\glsinsert{#3}%
\def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
\@gls@link[#1]{#2}{\@glo@text}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
\glspostlinkhook
}
\makeatother
\setabbreviationstyle[acronym]{long}
\newacronym
[
description=Evolutionary Strategy,
longplural=evolutionary strategies
]
{es}{ES}{evolutionary strategy}
\makeglossaries
\begin{document}
\printglossary[type=acronym,title={List of Acronyms}]
textbf{Singular:}
blablbla \gls{es}.
blablbla \glsxtrfull{es}.
blablbla \Gls{es}.
blablbla \Glsxtrfull{es}.
blablbla \myGls{es}.
blablbla \glsentrytitlecase{es}{long}.
\vspace*{1cm}
\textbf{Plural:}
blablbla \glspl{es}.
blablbla \glsxtrfullpl{es}.
blablbla \Glspl{es}.
blablbla \Glsxtrfullpl{es}.
blablbla \myGlspl{es}.
blablbla \glsentrytitlecase{es}{longpl}.
\end{document}
답변1
이것이 해결책입니다. 코드의 주석을 확인하세요. 두 번째로 짧은 형식을 표시하려면 해당 주석의 주석 처리를 해제하세요. 그렇지 않으면 항상 전체 양식이 표시됩니다. \myGlspl
복수형을 처리하려면 추가하세요 .
\documentclass[a4paper,12pt]{article}
\usepackage[hidelinks]{hyperref}
\usepackage[acronym,automake]{glossaries-extra}
\makeatletter
\newrobustcmd*{\myGls}{\@gls@hyp@opt\@myGls}
\newcommand*{\@myGls}[2][]{%
\new@ifnextchar[{\@myGls@{#1}{#2}}{\@myGls@{#1}{#2}[]}%
}
\def\@myGls@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
\let\glsifplural\@secondoftwo
\let\glscapscase\@secondofthree
\def\glscustomtext{%
\ifglsused{#2}
{\acronymfont\glsentryshort{#2}#3}
{%
\ecapitalisewords{\glsentrylong{#2}}#3\space%
\firstacronymfont(\glsentryshort{#2})}%
}%
\def\glsinsert{#3}%
\def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
\@gls@link[#1]{#2}{\@glo@text}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
\glspostlinkhook
}
\newrobustcmd*{\myGlspl}{\@gls@hyp@opt\@myGlspl}
\newcommand*{\@myGlspl}[2][]{%
\new@ifnextchar[{\@myGlspl@{#1}{#2}}{\@myGlspl@{#1}{#2}[]}%
}
\def\@myGlspl@#1#2[#3]{%
\glsdoifexists{#2}%
{%
\let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
\let\glsifplural\@firstoftwo
\let\glscapscase\@secondofthree
\def\glscustomtext{%
\ifglsused{#2}%
{\acronymfont\glsentryshortpl{#2}#3}
{%
\ecapitalisewords{\glsentrylongpl{#2}}#3\space%
\firstacronymfont(\glsentryshortpl{#2})}%
}%
\def\glsinsert{#3}%
\def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
\@gls@link[#1]{#2}{\@glo@text}%
\ifKV@glslink@local
\glslocalunset{#2}%
\else
\glsunset{#2}%
\fi
}%
\glspostlinkhook
}
\makeatother
\setabbreviationstyle[acronym]{long-short}
\newacronym{tla}{TLA}{three lettered acronym}
\makeglossaries
\begin{document}
\printglossary[type=acronym,title={List of Acronyms}]
\myGls{tla}
\myGlspl{tla}
\Gls{tla}
\end{document}