如何模仿 BibTeX change.case$ 内置命令?

如何模仿 BibTeX change.case$ 内置命令?

可能重复:
将字符串大写,忽略封闭类词

两者都bibtex.exe不能bibtex8.exe正确处理 unicoded 数据库。不过有些人(包括我)确实使用这些例程来编译参考列表。此类使用的示例提供了unicode-gost*.bst来自包的样式国家标准。这些样式避免使用change.case$原始样式,因为它会为西里尔字母产生错误的输出。

有人能告诉我如何编写 LaTeX 命令来转换

"Some Paper Title" to "Some paper title"

"Some Paper Title on {LaTeX}" to "Some paper title on {LaTeX}"

答案1

适应将字符串大写,忽略封闭类词可以尝试这个:

\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\uncapitalize}{>{\SplitList{~}}m}{
  \UncapitalizeFirst#1\Uncapitalize\unskip
}
\ExplSyntaxOff
\def\Sentinel{\Uncapitalize}

\makeatletter
\def\Uncapitalize#1{%
  \def\next{#1}%
  \ifx\next\Sentinel
    \expandafter\unskip
  \else
    \CheckInList{#1}\space\expandafter\Uncapitalize
  \fi}
\def\UncapitalizeFirst#1{\expandafter\UC@next#1 \Uncapitalize}
\def\CheckInList#1{%
  \ifcsname List@\detokenize{#1}\endcsname
    #1%
  \else
    \expandafter\UC@next#1%
  \fi}
\def\UC@next#1{%
  \ifx#1\UTFviii@two@octets
     \expandafter\@firstoffour
  \else
    \ifx#1\UTFviii@three@octets
      \expandafter\expandafter\expandafter\@secondoffour
    \else
      \ifx#1\UTFviii@four@octets
        \expandafter\expandafter\expandafter\expandafter\expandafter
        \@thirdoffour
      \else
        \expandafter\expandafter\expandafter\expandafter\expandafter
        \expandafter\expandafter\@fourthoffour
      \fi
    \fi
  \fi
  {\UC@two}{\UC@three}{\UC@four}{\MakeLowercase}#1}
\def\UC@two#1#2#3{\MakeLowercase{#1#2#3}}
\def\UC@three#1#2#3#4{\MakeLowercase{#1#2#3#4}}
\def\UC@four#1#2#3#4#5{\MakeLowercase{#1#2#3#4#5}}
\providecommand\@firstoffour[4]{#1}
\providecommand\@secondoffour[4]{#2}
\providecommand\@thirdoffour[4]{#3}
\providecommand\@fourthoffour[4]{#4}
\makeatother

\begin{document}
\uncapitalize{Here is a List of Words École}

\selectlanguage{russian}

\uncapitalize{Москва Спасибо}
\end{document}

不幸的是,它不适用于命令或支撑组。

相关内容