使用 paracol 時,如何停用特定列的連字?

使用 paracol 時,如何停用特定列的連字?

根據 Mico 的評論,對文本進行了一些更新(關於全部或僅部分連字)

我正在使用該包帕拉科爾使用 XeLaTeX,創建了兩列,並且我正在使用連字。我希望禁用第二列的罕見和歷史性連字,並將它們保留在第一列(至少目前如此)。常見的連字,例如FF,,等等,必須保留。

問題: 實現這目標最快、最簡單的方法是什麼?

額外更新:新增了屬於主要問題的另一個具體內容:第一件事解決後(即第二欄只允許使用普通連字),那麼如何繼續停用第一列中的某些特定連字?我的意思是:是的,我希望第一列具有歷史性和罕見的連字,除了一些特定的連字,例如雙但尤其是那些帶有兩個輔音的單字(例如克爾等等)。

更新代碼 (29-4-17):

\documentclass[12pt, a4paper, titlepage]{book}
\usepackage{paracol}
\usepackage{lipsum}
\usepackage{polyglossia}
\setmainlanguage{english}
\setmainfont[Ligature=Historic,Ligature=Rare]{Junicode}

\title{Title}
\author{Author}

\begin{document}
\frontmatter
   \begin{titlepage}
   \maketitle
   \thispagestyle{empty}
   \end{titlepage}


\chapter{Foreword}
\begin{paracol}{2}
   %% here starts the first column; while I wish to use the rare and 
    % historic ligatures in this first column, here I wish to disable e.g. 
   %  „gr” and „kr”
   \lipsum
   \switchcolumn
   %% having switched, here, for the second column, I want to disable the 
   % rare and historic ligatures, keep the common ones (ff, fi, etc.), and still use the 
   % same font as in the first, while the first column keeps all ligatures 
   % as it is
   \lipsum
\end{paracol}

\end{document}

答案1

這是一種半自動的方法。它是半自動的,因為在某些環境中您需要手動更改字體。該paracol包非常複雜,並且沒有提供按列設定字體的鉤子。

此程式碼自動適用於以下環境:

  • 簡單環境使用\switchcolumn
  • {leftcolumm}{rightcolumn}環境
  • 這些命令/環境的帶星標的版本

對於腳註、表格和圖形等其他環境,我提供了一個自動設定當前列號字體的命令:

\setcolfont

例如:

\footnote{\setcolfont Footnote text}

如果我找到一種更自動的方法,我會更新答案。

\documentclass{article}
\usepackage{paracol}
\usepackage{fontspec}
\usepackage{etoolbox}

% Define font families for Col 0 and Col 1
% Add more for more column documents if needed
\expandafter\newfontfamily\csname juni0\endcsname[Ligatures={Historic,Rare}]{Junicode}
\expandafter\newfontfamily\csname juni1\endcsname[]{Junicode}
% The following commands are added for convenience in case each font is needed elsewhere
% They also make the environment patching code more readable
\newfontfamily\junicodeHistoric[Ligatures={Historic,Rare}]{Junicode}
\newfontfamily\junicodeNoLig[]{Junicode}

% Patch the right and left column environments
\AtBeginEnvironment{leftcolumn}{\junicodeHistoric}
\AtBeginEnvironment{leftcolumn*}{\junicodeHistoric}
\AtBeginEnvironment{rightcolumn}{\junicodeNoLig}
\AtBeginEnvironment{rightcolumn*}{\junicodeNoLig}

\makeatletter
% Define a command to set the font to the current column number
\newcommand{\setcolfont}{%
\csname juni\number\pcol@currcol\endcsname%
}

%% Optional code for use with selnolig
%\usepackage{selnolig}
%% Define global noligs 
%\nolig{aa}{a|a} % Examples change as needed
%\nolig{al}{a|l}
%\nolig{an}{a|n}
%\nolig{ar}{a|r}
%\nolig{av}{a|v}
%% End optional code for selnolig


% Patch the \switchcolumn command and paracol environments to set the column font
\appto{\pcol@switchcol}{\setcolfont}{}{}
\preto{\paracol}{\setcolfont}{}{}
\makeatother

\usepackage[]{kantlipsum}
\begin{document}
\begin{paracol}{2}
% Test with switchcolumn
Ideal\kant[1]
\switchcolumn
After\kant[1]
% Test with leftcolumn/rightcolumn
\begin{leftcolumn}
\kant[2]%
% Footnotes need to have explicit \setcolfont commands
\footnote{\setcolfont 
This is a left column footnote.}
\end{leftcolumn}
\begin{rightcolumn}
\kant[2]%
\footnote{\setcolfont
This is a right column footnote.}
\end{rightcolumn}
\switchcolumn*
\kant[3]
% Tables/figures need to have explicit \setcolfont commands
\begin{table}[tbp]
\setcolfont
This is a left column table. Ideal It is set in the left font.
\end{table}
\switchcolumn
\kant[3]
\end{paracol}

\end{document}

程式碼的輸出

適應使用selnolig

如果您希望更好地控製文字中的連字,您可以使用 Mico 的selnolig套件選擇性地關閉某些連字。這需要 LuaTeX 才能運作。無法選擇性地關閉每列的連字,似乎\nolig命令實際上是全域的。 (請參閱下面 Mico 的評論。)

答案2

以下答案建立在@AlanMunn 的早期版本(暫時刪除,後來恢復)的答案之上。即,我保留使用etoolbox機器為左欄和右欄使用單獨的字體。此外,我從 XeLaTeX 切換到 LuaLaTeX,以便能夠使用塞爾諾利格包,它提供了一種全域禁用某些 Junicode 連字的方法,例如aaalanar的連字av。 (全面披露:我是這個包的主要作者。)

我相信從 XeLaTeX 切換到 LuaLaTeX 對您來說不會是一項艱鉅的任務。

在此輸入影像描述

\documentclass{article}
\usepackage{polyglossia} 
\setmainlanguage{english}
\usepackage{paracol,fontspec}
\newfontfamily\junicodeHistoric[Ligatures={Historic,Rare}]{Junicode}
\newfontfamily\junicodeNoLig[]{Junicode}

\usepackage{etoolbox}
\AtBeginEnvironment{leftcolumn}{\junicodeHistoric}
\AtBeginEnvironment{rightcolumn}{\junicodeNoLig}
\usepackage{kantlipsum}

\usepackage{selnolig} % must be used with LuaLaTeX
\debugon % optional -- leave an activity trail in log file
% Globally suppress the following ligatures:
\nolig{aa}{a|a} 
\nolig{al}{a|l}
\nolig{an}{a|n}
\nolig{ar}{a|r}
\nolig{av}{a|v}
% feel free to provide further \nolig directives...

\begin{document}
\begin{paracol}{2}
\begin{leftcolumn}
\kant[1]
\end{leftcolumn}
\begin{rightcolumn}
\kant[1]
\end{rightcolumn}
\end{paracol}

\end{document}

相關內容