csquotes 和 foreignlanguages:设置引号的外部语言

csquotes 和 foreignlanguages:设置引号的外部语言

包 csquotes 定义了来自(=内部) 语言,而不是来自环境语言。

如何设置\foreignquote用于定义和引号的语言\foreignblockcquote

编辑:我正在寻找一种产生引号的方法语言切换和参考(如果有)语言已切换回来。

例如\foreignquote

\documentclass[11pt,a4paper,french,english]{article} 
  \usepackage[utf8]{inputenc} 
   \usepackage[T1]{fontenc} 
   \usepackage[autostyle=true]{csquotes} 
   \usepackage{babel} 
   \begin{document}     
   \selectlanguage{english}     In an English paper, 
   if I quote something that is in French, 
  I have guillemets: \foreignquote{french}{Ceci est en français.}       
  I am looking for \enquote{\selectlanguage{french}Ceci est en français.} 
  \end{document}

\foreignquote 示例

例如\foreignblockcquote

    \selectlanguage{english}    In an English paper, 
       if I quote something that is in French, 
\foreignblockcquote{french}{REF}{Ceci est en \enquote{français}.}
%      I have guillemets: \foreignblockcquote{french}{REF}{Ceci est en \enquote{français}}.}        
      I am looking for \blockcquote{REF}{\selectlanguage{french}Ceci est en \og français \fg.\selectlanguage{english}} 

\foreignblockcquote 示例

注意:我\selectlanguage{english}在 \blockcquote 末尾添加了引用,以便使用论文的主要语言(这里是英语)。

答案1

我找不到csquotes允许您执行此操作的官方界面,但您可以重新定义一些内部宏,以便csquotes首先生成引号,然后再切换语言。

\documentclass[11pt,a4paper,french,english]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[autostyle=true]{csquotes}

\makeatletter
%  {<init>}{<endinit>}{<text>}
\long\def\csq@quote@i#1#2#3{%
  \csq@bqgroup\csq@oqopen@i#1#3#2\csq@qclose@i{}}
\long\def\csq@quote@ii#1#2#3{%
  \csq@bqgroup\csq@iqopen@i#1#3#2\csq@qclose@i{}}
\makeatother

\begin{document}
  In an English paper, if I quote something that is in French,
  I have guillemets: \foreignquote{french}{Ceci est en français.}
  
  I am looking for \enquote{\selectlanguage{french}Ceci est en français.}
\end{document}

我正在寻找“Ceci est en français。”


如果您要重置引号级别,以便外语引文从外层开始,则需要深入挖掘。

以下解决方案也应该可以解决大多数块语言切换命令。

\documentclass[11pt,a4paper,french,english]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[autostyle=true]{csquotes}
\usepackage[backend=biber, style=authoryear]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\newcount\saved@csq@qlevel

\newcommand*{\tcsq@saveandreset@qlevel}{%
  \saved@csq@qlevel\csq@qlevel
  \csq@qlevel\z@}
  
\newcommand*{\tcsq@restore@qlevel}{%
  \csq@qlevel\saved@csq@qlevel}

%  {<init>}{<endinit>}{<text>}
\long\def\csq@quote@i#1#2#3{%
  \csq@bqgroup\csq@oqopen@i#1#3#2\csq@qclose@i{}}
\long\def\csq@quote@ii#1#2#3{%
  \csq@bqgroup\csq@iqopen@i#1#3#2\csq@qclose@i{}}


\def\csq@fquote@i#1{\csq@quote@i{\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}}
\def\csq@fquote@ii#1{\csq@quote@ii{\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}}
\def\csq@hquote@i#1{\csq@quote@i{\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}}
\def\csq@hquote@ii#1{\csq@quote@ii{\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}}

% {<init>}{<endinit>}{<qopen>}{<citehook>}{<cite>}{<punct>}{<text>}{<apunct>}<tpunct>
\long\def\csq@tquote@i#1#2#3#4#5#6#7#8#9{%
  \begingroup
  \csq@setsfcodes
  \edef\csq@tempa{%
    \unexpanded{%
      \mktextquote
      {#3}%
      {#1#7}%
      {#2\csq@qclose@i{}}%
      {#6}{#8}}%
    {\ifblank{#5}
       {}
       {\unexpanded{\csq@switchlang{#4{#5}}}}}}%
  \csq@bqgroup\csq@tempa#9%
  \endgroup}

\def\csq@ftquote@i#1{%
  \csq@getcargs{\csq@tquote
    {\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}
    {\csq@oqopen@i}}}
\def\csq@ftquote@ii#1{%
  \csq@getcargs{\csq@tquote
    {\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}
    {\csq@iqopen@i}}}

\def\csq@htquote@i#1{%
  \csq@getcargs{\csq@tquote
    {\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}
    {\csq@oqopen@i}}}
\def\csq@htquote@ii#1{%
  \csq@getcargs{\csq@tquote
    {\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}
    {\csq@iqopen@i}}}

\def\csq@ftcquote@i#1{%
  \csq@getccargs{\csq@tquote
    {\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}
    {\csq@oqopen@i}}}
\def\csq@ftcquote@ii#1{%
  \csq@getccargs{\csq@tquote
    {\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}
    {\csq@iqopen@i}}}
  
\def\csq@htcquote@i#1{%
  \csq@getccargs{\csq@tquote
    {\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}
    {\csq@oqopen@i}}}
\def\csq@htcquote@ii#1{%
  \csq@getccargs{\csq@tquote
    {\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}
    {\csq@iqopen@i}}}

% {<init>}{<endinit>}{<citehook>}{<cite>}{<punct>}{<text>}{<apunct>}<tpunct>

\def\csq@bquote@ii#1#2#3#4#5#6#7#8{\csq@tquote@i{}{}{\csq@oqopen@i}{#3}{#4}{#5}{#1#6#2}{#7}{#8}}

% {<init>}{<endinit>}{<citehook>}{<cite>}{<punct>}{<text>}{<apunct>}<tpunct>

\long\def\csq@bquote@iii#1#2#3#4#5#6#7#8{%
  \begin{\csq@blockenvironment}%
  \toggletrue{csq@block}%
  \csq@setsfcodes
  \edef\csq@tempa{%
    \unexpanded{%
      \mkblockquote
      {#1#6}%
      {#5}{#7}}%
    {#2\ifblank{#4}
       {}
       {\unexpanded{\csq@switchlang{#3{#4}}}}}}%
  \csq@tempa#8%
  \end{\csq@blockenvironment}}

\renewrobustcmd*{\foreignblockquote}[1]{%
  \csq@getcargs{\csq@bquote{\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}}}

\renewrobustcmd*{\hyphenblockquote}[1]{%
  \csq@getcargs{\csq@bquote{\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}}}

\renewrobustcmd*{\hybridblockquote}[1]{%
  \csq@getcargs{%
    \csq@bquote
      {\iftoggle{csq@block}{\csq@lang}{\csq@hyph}{#1}\tcsq@saveandreset@qlevel}
      {\tcsq@restore@qlevel\iftoggle{csq@block}{\csq@endlang}{\csq@endhyph}}}}

\renewrobustcmd*{\foreignblockcquote}[1]{%
  \csq@getccargs{\csq@bquote{\csq@lang{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endlang}}}

\renewrobustcmd*{\hyphenblockcquote}[1]{%
  \csq@getccargs{\csq@bquote{\csq@hyph{#1}\tcsq@saveandreset@qlevel}{\tcsq@restore@qlevel\csq@endhyph}}}

\renewrobustcmd*{\hybridblockcquote}[1]{%
  \csq@getccargs{%
    \csq@bquote
      {\iftoggle{csq@block}{\csq@lang}{\csq@hyph}{#1}\tcsq@saveandreset@qlevel}
      {\tcsq@restore@qlevel\iftoggle{csq@block}{\csq@endlang}{\csq@endhyph}}}}
\makeatother

\SetCiteCommand{\autocite}
\usepackage{lipsum}

\begin{document}
  Lorem \foreignquote{french}{Ceci est en français.}
  
  Lorem \foreignquote{french}{Ceci \enquote{\enquote{est} en} français.}
  
  Lorem \foreigntextquote{french}{Ceci \enquote{\enquote{est} en} français.}
  
  Lorem \foreignblockcquote{french}{sigfridsson}{Ceci est en \enquote{français}.}
  
  Lorem \foreignblockcquote{french}{sigfridsson}{Ceci est en \enquote{français}. \lipsum}
\end{document}

答案2

如果我理解正确的话这应该足够了:

\DeclareQuoteStyle{french}
  {\textquotedblleft}
  {\textquotedblright}
  {\textquoteleft}
  {\textquoteright}

您可以使用以下命令将内部引号更改为«...»:

\DeclareQuoteStyle{french}
  {\textquotedblleft}
  {\textquotedblright}
  {\guillemotleft}
  {\guillemotright}

所以这个代码

 \foreignquote{french}{Ceci est en français: \enquote{Il l'a dit}}

给出:

在此处输入图片描述

相关内容