使用 Linux Libertine 的连字符对章节和目录进行编号

使用 Linux Libertine 的连字符对章节和目录进行编号

旧的 Libertine 包与 pdfTeX 配合使用,包含一个命令\libertineGlyph{}.println \libertineGlyph{Fourroman}( "

但是我怎样才能使用这些罗马数字来编号章节甚至目录呢?

我发现在 pdftex 中使用 libertine 的连字符表示罗马数字,但我不知道如何让它工作。

梅威瑟:

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}
\usepackage{babel,blindtext}
 \usepackage{libertine}


\newcommand*{\libertineRoman}[1]{%
    \def\Romantemp{}%
    \ifnum\value{#1}>0\relax%
        \ifnum\value{#1}<13\relax%
            \edef\Romantemp{\ifcase\value{#1}\or One\or Two\or Three\or Four\or Five\or Six\or Seven\or Eight\or Nine\or Ten\or Eleven\or Twelve\fi}%
            \libertineGlyph{\Romantemp roman}%
        \else\Roman{#1}\fi%
    \else\Roman{#1}\fi%
}
\newcommand*{\libertineroman}[1]{%
    \def\Romantemp{}%
    \ifnum\value{#1}>0\relax%
        \ifnum\value{#1}<13\relax%
            \edef\Romantemp{\ifcase\value{#1}\or one\or two\or three\or four\or five\or six\or seven\or eight\or nine\or ten\or eleven\or twelve\fi}%
            \libertineGlyph{\Romantemp roman}%
        \else\roman{#1}\fi%
    \else\roman{#1}\fi%
}


%%% Roman numbers
\renewcommand{\thesection}{\Roman{section}}

%%% Roman ligatures from Linux Libertine?
%\renewcommand{\thesection}{\libertineRoman{section}}
%%% DOES NOT WORK


\begin{document}
\tableofcontents{}

{\libertineGlyph{Fourroman}} 

\blinddocument

\end{document}

Cave:我使用几年前的旧 libertine 包,它为 pdfTeX 提供了 \libertineGlyph。不过,也许有人可以给我一点提示。

答案1

新的libertine软件包还提供了\libertineGlyph是否使用 XeLaTeX 或 LuaLaTeX。这使我能够在不安装旧软件包的情况下找到解决方案。该代码也适用于旧软件包。

\arabic如果你不想遇到麻烦,计数器表示命令应该是可扩展的。但是你的命令不可扩展。

下面我定义了五个命令:

  • \LibertineRomanByName{<name>}-- 的快捷方式\libertineGlyph{<name>roman}
  • \LibertineUCRomanByInt{<integer>}-- 为给定的整数提供大写的自由字形(只要该整数在 1--12 范围内)。
  • \LibertineLCRomanByInt{<integer>}-- 为给定的整数提供小写的自由字形(只要该整数在 1--12 范围内)。
  • \lbtRoman{<counter>}\Roman-- 为相应的计数器值提供大写的自由字形,或者当计数器超出范围时通常的结果。
  • \lbtroman{<counter>}\roman-- 为相应的计数器值提供小写的自由字形,或者当计数器超出范围时通常的结果。

代码

Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\setcounter{section}{7}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\setcounter{section}{13}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\LibertineUCRomanByInt{1} \LibertineLCRomanByInt{1}\par
\LibertineUCRomanByInt{2} \LibertineLCRomanByInt{2}\par
\LibertineUCRomanByInt{3} \LibertineLCRomanByInt{3}\par
\LibertineUCRomanByInt{4} \LibertineLCRomanByInt{4}\par
\LibertineUCRomanByInt{5} \LibertineLCRomanByInt{5}\par
\LibertineUCRomanByInt{6} \LibertineLCRomanByInt{6}\par
\LibertineUCRomanByInt{7} \LibertineLCRomanByInt{7}\par
\LibertineUCRomanByInt{8} \LibertineLCRomanByInt{8}\par
\LibertineUCRomanByInt{9} \LibertineLCRomanByInt{9}\par
\LibertineUCRomanByInt{10} \LibertineLCRomanByInt{10}\par
\LibertineUCRomanByInt{11} \LibertineLCRomanByInt{11}\par
\LibertineUCRomanByInt{12} \LibertineLCRomanByInt{11}

\setcounter{section}{7}
\renewcommand*\thesection{\lbtRoman{section}}
\section{Let's see: it works!}

然后给出

在此处输入图片描述

完整代码如下:

% arara: lualatex
\documentclass{article}
\usepackage{libertine}

\makeatletter
\newcommand*\LibertineRomanByName[1]{\libertineGlyph{#1roman}}
\newcommand*\LibertineUCRomanByInt[1]{%
  \ifcase#1%
  \or\LibertineRomanByName{One}%
  \or\LibertineRomanByName{Two}%
  \or\LibertineRomanByName{Three}%
  \or\LibertineRomanByName{Four}%
  \or\LibertineRomanByName{Five}%
  \or\LibertineRomanByName{Six}%
  \or\LibertineRomanByName{Seven}%
  \or\LibertineRomanByName{Eight}%
  \or\LibertineRomanByName{Nine}%
  \or\LibertineRomanByName{Ten}%
  \or\LibertineRomanByName{Eleven}%
  \or\LibertineRomanByName{Twelve}%
  \fi
}
\newcommand*\LibertineLCRomanByInt[1]{%
  \ifcase#1%
  \or\LibertineRomanByName{one}%
  \or\LibertineRomanByName{two}%
  \or\LibertineRomanByName{three}%
  \or\LibertineRomanByName{four}%
  \or\LibertineRomanByName{five}%
  \or\LibertineRomanByName{six}%
  \or\LibertineRomanByName{seven}%
  \or\LibertineRomanByName{eight}%
  \or\LibertineRomanByName{nine}%
  \or\LibertineRomanByName{ten}%
  \or\LibertineRomanByName{eleven}%
  \or\LibertineRomanByName{twelve}%
  \fi
}

\newcommand*\lbtRoman[1]{\expandafter\@lbtRoman\csname c@#1\endcsname}
\newcommand*\@lbtRoman[1]{%
  \ifnum#1=0
    0%
  \else
    \ifnum#1<13
      \LibertineUCRomanByInt{#1}%
    \else
      \@Roman{#1}%
    \fi
  \fi
}

\newcommand*\lbtroman[1]{\expandafter\@lbtroman\csname c@#1\endcsname}
\newcommand*\@lbtroman[1]{%
  \ifnum#1=0
    0%
  \else
    \ifnum#1<13
      \LibertineLCRomanByInt{#1}%
    \else
      \@roman{#1}%
    \fi
  \fi
}

\makeatother

\begin{document}

Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\setcounter{section}{7}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\setcounter{section}{13}
Uppercase: \lbtRoman{section}, lowercase: \lbtroman{section}

\LibertineUCRomanByInt{1} \LibertineLCRomanByInt{1}\par
\LibertineUCRomanByInt{2} \LibertineLCRomanByInt{2}\par
\LibertineUCRomanByInt{3} \LibertineLCRomanByInt{3}\par
\LibertineUCRomanByInt{4} \LibertineLCRomanByInt{4}\par
\LibertineUCRomanByInt{5} \LibertineLCRomanByInt{5}\par
\LibertineUCRomanByInt{6} \LibertineLCRomanByInt{6}\par
\LibertineUCRomanByInt{7} \LibertineLCRomanByInt{7}\par
\LibertineUCRomanByInt{8} \LibertineLCRomanByInt{8}\par
\LibertineUCRomanByInt{9} \LibertineLCRomanByInt{9}\par
\LibertineUCRomanByInt{10} \LibertineLCRomanByInt{10}\par
\LibertineUCRomanByInt{11} \LibertineLCRomanByInt{11}\par
\LibertineUCRomanByInt{12} \LibertineLCRomanByInt{11}

\setcounter{section}{7}
\renewcommand*\thesection{\lbtRoman{section}}
\section{Let's see: it works!}

\end{document}

相关内容