我正在使用parallel
包来并排编写不同翻译的文本,我发现parallel
包完成了并排文本,这里左栏是另一种语言,右栏是左栏文本的英语翻译,这里我遇到一个问题,当我们使用\textcolor{red}{ some long texts}
它时应该给出红色即使我没有输入\textcolor{red}
命令其他文本也变成红色,这里Jesus said to him
变成红色但在我的代码中没有\textcolor{Jesus said to him}
,为什么它会给出红色,如何在乳胶中解决这个问题。这是我的MWE。
\documentclass[twoside,letterpaper,11pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage[T1]{fontenc}
%\usepackage[english]{babel} %% This package make sure for hyphenation problem
\usepackage{ebgaramond}
\usepackage{lipsum}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{parallel,graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO,LE]{\rightmark}
% \fancyhead[RO,LE]{\leftmark} %% display chapter in header
\renewcommand{\headrulewidth}{.5pt}
\fancyhead[LO,RE]{\thepage} %% To display numbering on every page alternately left and right
% \fancyhead[LO]{\small\thetitle} % Odd page header and number to right top
% \fancyhead[RE]{\small\thetitle} % Even page header and number at left top
\setlength{\headwidth}{\textwidth}
\setlength{\headheight}{15pt}
\setlength{\headsep}{0pt}
\setlength{\columnseprule}{0pt}
\usepackage[colorlinks]{hyperref}
\newcommand{\jChapter}[1]{\noindent\scalebox{2.5}{\color{red}\textbf{#1}\hspace{0.3mm}}}
\newcommand{\jverse}[1]{\noindent\textcolor{cyan}{\scalebox{1.0}{\textbf{#1\hspace{1.0mm}}}}}
%% Starts Add
%\newcommand{\story}[1]{\hfill\large\it\textbf{#1}\hfill~}
\newcommand{\story}[1]{\vspace*{2mm}\centering\it\textbf{#1}}
%%%% End Add
\makeatletter
\newcommand\versenumcolor{red}
\newcommand\chapnumcolor{red}
\renewcommand\paragraph{%
\@startsection{paragraph}{4}{\z@}%
{.25ex \@plus.25ex \@minus.1ex}%
{-.5em}%
{\normalfont\normalsize\bfseries\color{\versenumcolor}}}%
\newlength{\biblechapskip}
\setlength{\biblechapskip}{1em plus .33em minus .2em}
\newcounter{biblechapter}
\newcounter{bibleverse}[biblechapter]
\renewcommand\chaptername{Book}
\let\ltx@chapter=\chapter
\let\ltx@paragraph=\paragraph
\newcommand{\book}[1]{%
\gdef\currbook{#1}
\ltx@chapter{#1}}
\newcount\biblechap@svdopt
\newenvironment{biblechapter}[1][\thebiblechapter]
{\biblechap@svdopt=#1
\ifnum\c@biblechapter=\biblechap@svdopt\else
\advance\biblechap@svdopt by -1\fi
\setcounter{biblechapter}{\the\biblechap@svdopt}
\refstepcounter{biblechapter}
\lettrine{\color{\chapnumcolor}\lower-6pt\hbox{\thebiblechapter}}{}\ignorespaces}
{\vspace{\biblechapskip}}
\renewcommand{\verse}[1][\thebibleverse]{%
\refstepcounter{bibleverse}
\markright{{\scshape\currbook} \thebiblechapter:\thebibleverse}
\ifnum\c@bibleverse=1\else
\ltx@paragraph*{#1}\fi}%
\makeatother
\title{Translation}
\date{}
\author{}
\usepackage{lipsum}
\usepackage{ragged2e}
\newcommand{\BookLine}{ \centering\noindent\rule{19cm}{1pt}}
\newcommand{\BookNote}[1]{{\begin{center} \textbf{KEPACHINI} \justify
#1
\end{center}
\BookLine
\vspace{2mm}
}}
\usepackage[perpage]{footmisc} %%% To restart footnote numbering on every new pages
\begin{document}
\renewcommand{\thefootnote}{\emph{\alph{footnote}}}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\setlength{\columnseprule}{.5pt}
\begin{Parallel}{9.0cm}{9.0cm}
\ParallelLText{\jverse{9}Jisu thakddunsi pulo, \textcolor{red}{``Philip, ne lapu-an arni keding nangtum along nangkedodun anta nangtum nephan nechininelangma? Nephan nekethek-long abang ke Po aphanta thek-long-lo. Tangte nang kopisi, `Netum aphan Po nepaklangtha,' pu kepulangma?}}
\ParallelRText{\jverse{9}Jesus said to him, \textcolor{red}{``Have I been with you all this time, Philip, and you still do not know me? Whoever has seen me has seen the Father. How can you say, `Show us the Father'?}}
\ParallelPar
\end{Parallel}
\end{document}
答案1
事实证明,答案甚至更简单。Heiko Oberdiek 编写了一个软件包pdfcolparallel
,修复了使用颜色堆栈时出现的这个错误parallel
。(可以说,这个问题应该通过替换自 2003 年以来被废弃的有缺陷的软件包来解决,而不是添加第二个名称不同的软件包。)
和以前一样,我使用 LuaLaTeX 进行编译,删除了该fontenc
包,因为ebgaramond
LuaLaTeX 会加载更现代的 OpenType 版本,并添加了microtype
该包以改进左列的连字符。
\documentclass[twoside,letterpaper,11pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{pdfcolparallel, graphicx, microtype}
\usepackage[oldstyle]{ebgaramond}
\usepackage[colorlinks, unicode]{hyperref}
\newcommand{\jverse}[1]{\noindent\textcolor{cyan}{\scalebox{1.0}{\textbf{#1\hspace{1.0mm}}}}}
\begin{document}
\begin{Parallel}{9.0cm}{9.0cm}
\ParallelLText{\jverse{9}Jisu thakddunsi pulo, \textcolor{red}{``Philip, ne lapu-an arni keding nangtum along nangkedodun anta nangtum nephan nechininelangma? Nephan nekethek-long abang ke Po aphanta thek-long-lo. Tangte nang kopisi, `Netum aphan Po nepaklangtha,' pu kepulangma?}}
\ParallelRText{\jverse{9}Jesus said to him, \textcolor{red}{``Have I been with you all this time, Philip, and you still do not know me? Whoever has seen me has seen the Father. How can you say, `Show us the Father'?}}
\ParallelPar
\end{Parallel}
\end{document}
您可能仍会考虑为红字文本添加一个更具语义的命令,以防万一您想使用不同的红色色调。目前,有很多\textcolor{red}
命令需要更改,而且并非所有命令(即使在您的 MWE 中)都与耶稣在福音书中的陈述有关。因此,如果您需要更改样式,您无法对它们进行搜索和替换。
定义\redletter Red-letter text
和\textred{Red-letter text}
:
\newcommand\redletter{\color{red}}
\DeclareTextFontCommand\textred{\redletter}
答案2
让颜色在 tex 中自然地发挥作用确实很棘手....在这里我只需简单地将其强制恢复为黑色即可
\jverse{9}\textcolor{black}{Jesus said to him,} \textcolor{red}{``Have I been...
如果可以使用 lualatex,那么您可以使用luacolor
保留相同color
或xcolor
您习惯的命令的包,但使用完全不同的机制在内部记录颜色,其行为更像字体变化,因此拆分框不会导致颜色泄漏,就像经典 tex 颜色机制那样。
对于此处的示例,这将按预期将每列中的第一个短语显示为黑色:
我只做了两处更改,删除了fontenc
软件包并添加了luacolor
软件包。实际文档文本没有更改。
\documentclass[twoside,letterpaper,11pt]{book}
\usepackage[margin=1.5cm]{geometry}
% not for luatex \usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{luacolor}% load after xcolor
%\usepackage[english]{babel} %% This package make sure for hyphenation problem
\usepackage{ebgaramond}
\usepackage{lipsum}
\usepackage{parallel,graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO,LE]{\rightmark}
% \fancyhead[RO,LE]{\leftmark} %% display chapter in header
\renewcommand{\headrulewidth}{.5pt}
\fancyhead[LO,RE]{\thepage} %% To display numbering on every page alternately left and right
% \fancyhead[LO]{\small\thetitle} % Odd page header and number to right top
% \fancyhead[RE]{\small\thetitle} % Even page header and number at left top
\setlength{\headwidth}{\textwidth}
\setlength{\headheight}{15pt}
\setlength{\headsep}{0pt}
\setlength{\columnseprule}{0pt}
\usepackage[colorlinks]{hyperref}
\newcommand{\jChapter}[1]{\noindent\scalebox{2.5}{\color{red}\textbf{#1}\hspace{0.3mm}}}
\newcommand{\jverse}[1]{\noindent\textcolor{cyan}{\scalebox{1.0}{\textbf{#1\hspace{1.0mm}}}}}
%% Starts Add
%\newcommand{\story}[1]{\hfill\large\it\textbf{#1}\hfill~}
\newcommand{\story}[1]{\vspace*{2mm}\centering\it\textbf{#1}}
%%%% End Add
\makeatletter
\newcommand\versenumcolor{red}
\newcommand\chapnumcolor{red}
\renewcommand\paragraph{%
\@startsection{paragraph}{4}{\z@}%
{.25ex \@plus.25ex \@minus.1ex}%
{-.5em}%
{\normalfont\normalsize\bfseries\color{\versenumcolor}}}%
\newlength{\biblechapskip}
\setlength{\biblechapskip}{1em plus .33em minus .2em}
\newcounter{biblechapter}
\newcounter{bibleverse}[biblechapter]
\renewcommand\chaptername{Book}
\let\ltx@chapter=\chapter
\let\ltx@paragraph=\paragraph
\newcommand{\book}[1]{%
\gdef\currbook{#1}
\ltx@chapter{#1}}
\newcount\biblechap@svdopt
\newenvironment{biblechapter}[1][\thebiblechapter]
{\biblechap@svdopt=#1
\ifnum\c@biblechapter=\biblechap@svdopt\else
\advance\biblechap@svdopt by -1\fi
\setcounter{biblechapter}{\the\biblechap@svdopt}
\refstepcounter{biblechapter}
\lettrine{\color{\chapnumcolor}\lower-6pt\hbox{\thebiblechapter}}{}\ignorespaces}
{\vspace{\biblechapskip}}
\renewcommand{\verse}[1][\thebibleverse]{%
\refstepcounter{bibleverse}
\markright{{\scshape\currbook} \thebiblechapter:\thebibleverse}
\ifnum\c@bibleverse=1\else
\ltx@paragraph*{#1}\fi}%
\makeatother
\title{Translation}
\date{}
\author{}
\usepackage{lipsum}
\usepackage{ragged2e}
\newcommand{\BookLine}{ \centering\noindent\rule{19cm}{1pt}}
\newcommand{\BookNote}[1]{{\begin{center} \textbf{KEPACHINI} \justify
#1
\end{center}
\BookLine
\vspace{2mm}
}}
\usepackage[perpage]{footmisc} %%% To restart footnote numbering on every new pages
\begin{document}
\renewcommand{\thefootnote}{\emph{\alph{footnote}}}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\setlength{\columnseprule}{.5pt}
\begin{Parallel}{9.0cm}{9.0cm}
\ParallelLText{\jverse{9}Jisu thakddunsi pulo, \textcolor{red}{``Philip, ne lapu-an arni keding nangtum along nangkedodun anta nangtum nephan nechininelangma? Nephan nekethek-long abang ke Po aphanta thek-long-lo. Tangte nang kopisi, `Netum aphan Po nepaklangtha,' pu kepulangma?}}
\ParallelRText{\jverse{9}Jesus said to him, \textcolor{red}{``Have I been with you all this time, Philip, and you still do not know me? Whoever has seen me has seen the Father. How can you say, `Show us the Father'?}}
\ParallelPar
\end{Parallel}
\end{document}
答案3
David Carlisle 的出色答案的另一种选择是从过时的 8 位编码切换到fontspec
并使用其Color
选项。这样您就可以使用 Unicode 以及您可以在文字处理器中使用的任何标准字体。
事实上,您可以通过添加luacolor
包将其与他的答案结合起来。
设置Color=
字体选项与不兼容\textcolor
,xcolor
因此您还必须更新要使用的其他更改颜色的命令\addfontfeatures
。
我还擅自添加了\usepackage{microtype}
。如果您使用 LuaLaTeX 进行编译,其字体扩展应该会大大减少您在连字和自动换行方面遇到的问题。
\documentclass[twoside,letterpaper,11pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{parallel,graphicx, fontspec, microtype}
\usepackage[oldstyle]{ebgaramond}
\usepackage[colorlinks, unicode]{hyperref}
\newcommand{\jChapter}[1]{\noindent\scalebox{2.5}{\addfontfeature{Color=red}\textbf{#1}\hspace{0.3mm}}}
\newcommand{\jverse}[1]{\noindent\scalebox{1.0}{\addfontfeature{Color=cyan}\textbf{#1\hspace{1.0mm}}}}
\newcommand\redletter{\addfontfeature{Color=red}}
\DeclareTextFontCommand\textred{\redletter}
\newcommand\uncolor{\addfontfeature{Color=black}}
\DeclareTextFontCommand\textblack{\uncolor}
\begin{document}
\begin{Parallel}{9.0cm}{9.0cm}
\ParallelLText{\jverse{9}Jisu thakddunsi pulo, \textred{``Philip, ne lapu-an arni keding nangtum along nangkedodun anta nangtum nephan nechininelangma? Nephan nekethek-long abang ke Po aphanta thek-long-lo. Tangte nang kopisi, `Netum aphan Po nepaklangtha,' pu kepulangma?}}
\ParallelRText{\jverse{9}Jesus said to him, \textred{``Have I been with you all this time, Philip, and you still do not know me? Whoever has seen me has seen the Father. How can you say, `Show us the Father'?}}
\ParallelPar
\end{Parallel}
\end{document}
这将添加新命令。\redlettter Text in red,
\textred{Text in red}
这将需要更改您的源代码,但如果您愿意,至少可以很容易地将红字文本更改为其他样式或阴影。
如果搜索和替换不可行,您也可以(尽管我不推荐这样做)更改with\textcolor
的含义。\textcolor
\renewcommand
答案4
谢谢大家的回答,现在我想出了我的问题的新解决方案,在这里我发布我的答案,以便其他人不会像我一样遇到基于这个问题的问题,在这里我删除了parallel
包\textcolor
它不能正常工作,所以我搜索互联网https://ctan.org/topic/parallel我发现名为的包paracol
可以\textcolor
正常工作,并且保持相同的文本字体,我将源重新定义为
\newcommand{\ParallelLText}[2]{\begin{paracol}{2}\sloppy \switchcolumn[0]\noindent #1 \switchcolumn[1]\noindent #2 \end{paracol}}
只是为了满足包的要求parcol
这里是我的代码
\documentclass[oneside,letterpaper,11pt]{book}
\usepackage[margin=1.5cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{ebgaramond}
\usepackage{lipsum}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{paracol}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO,LE]{\rightmark}
\fancyhead[RO,LE]{\leftmark} %% display chapter in header
\renewcommand{\headrulewidth}{.5pt}
\fancyhead[LO,RE]{\thepage} %% To display numbering on every page alternately left and right
% \fancyhead[LO]{\small\thetitle} % Odd page header and number to right top
% \fancyhead[RE]{\small\thetitle} % Even page header and number at left top
\setlength{\headwidth}{\textwidth}
\setlength{\headheight}{15pt}
\setlength{\headsep}{0pt}
\setlength{\columnseprule}{0pt}
\usepackage[colorlinks]{hyperref}
\newcommand{\jChapter}[1]{\noindent\scalebox{2.5}{\color{red}\textbf{#1}\hspace{0.3mm}}}
\newcommand{\jverse}[1]{\noindent\textcolor{cyan}{\scalebox{1.0}{\textbf{#1\hspace{1.0mm}}}}\color{black}}
%% Starts Add by Biki from Net
%\newcommand{\story}[1]{\hfill\large\it\textbf{#1}\hfill~}
\newcommand{\story}[1]{\vspace*{2mm}\centering\it\textbf{#1}}
%%%% End Add
\makeatletter
\newcommand\versenumcolor{red}
\newcommand\chapnumcolor{red}
\renewcommand\paragraph{%
\@startsection{paragraph}{4}{\z@}%
{.25ex \@plus.25ex \@minus.1ex}%
{-.5em}%
{\normalfont\normalsize\bfseries\color{\versenumcolor}}}%
\newlength{\biblechapskip}
\setlength{\biblechapskip}{1em plus .33em minus .2em}
\newcounter{biblechapter}
\newcounter{bibleverse}[biblechapter]
\renewcommand\chaptername{Book}
\let\ltx@chapter=\chapter
\let\ltx@paragraph=\paragraph
\newcommand{\book}[1]{%
\gdef\currbook{#1}
\ltx@chapter{#1}}
\newcount\biblechap@svdopt
\newenvironment{biblechapter}[1][\thebiblechapter]
{\biblechap@svdopt=#1
\ifnum\c@biblechapter=\biblechap@svdopt\else
\advance\biblechap@svdopt by -1\fi
\setcounter{biblechapter}{\the\biblechap@svdopt}
\refstepcounter{biblechapter}
\lettrine{\color{\chapnumcolor}\lower-6pt\hbox{\thebiblechapter}}{}\ignorespaces}
{\vspace{\biblechapskip}}
\renewcommand{\verse}[1][\thebibleverse]{%
\refstepcounter{bibleverse}
\markright{{\scshape\currbook} \thebiblechapter:\thebibleverse}
\ifnum\c@bibleverse=1\else
\ltx@paragraph*{#1}\fi}%
\makeatother
\title{Translation}
\date{}
\author{}
\usepackage{lipsum}
\usepackage{ragged2e}
\newcommand{\BookLine}{ \centering\noindent\rule{19cm}{1pt}}
\newcommand{\BookNote}[1]{{\begin{center} \textbf{KEPACHINI} \justify
#1
\end{center}
\BookLine
\vspace{2mm}
}}
\newcommand{\ParallelLText}[2]{\begin{paracol}{2}\sloppy \switchcolumn[0]\noindent #1 \switchcolumn[1]\noindent #2 \end{paracol}}
\usepackage[perpage]{footmisc} %%% To restart footnote numbering on every new pages
\begin{document}
\renewcommand{\thefootnote}{\emph{\alph{footnote}}}
\frontmatter
\maketitle
\tableofcontents
\mainmatter
\ParallelLText{\jverse{9}Jisu thakdunsi pulo, \textcolor{red}{“Philip, ne lapu-an arni keding nangtum along nangkedodun anta nangtum nephan nechininelangma? Nephan nekethek-long abang ke Po aphanta thek-long-lo. Tangte nang kopisi, ‘Netum aphan Po nepaklangtha,’ pu kepulangma? }}{\jverse{9}Jesus said to him, \textcolor{red}{“Have I been with you all this time, Philip, and you still do not know me? Whoever has seen me has seen the Father. How can you say, ‘Show us the Father’? }}
\end{document}