0

I'm using with lualatex 1.12 the package csquotes for proper quotation in German. The package parses if matching quotes are found and if not it complains. My question is: Is there a possibility to scan the text even if the quote is NOT set in the same group?

e.g. Beginning quote without bold but ending within, i.e. "Wrong" text

\documentclass{article}
\usepackage[german]{babel}
\usepackage{csquotes}
\MakeOuterQuote{"}
\begin{document}
    \enquote{Bold text 1}
    "{\bfseries{}Bold text2}"
    "{\bfseries{}Wrong" text3}
\end{document}

The desired solution would be to have the quotation marks set properly despite the the group.

2

Essentially no. csquotes works with grouping and that grouping is deeply engrained into all of csquotes' code. (Grouping makes it possible to implement nested quotations without a lot of additional unnecessary bookkeeping.)

Here is an attempt to completely remove any grouping from the quotation commands used by \MakeOuterQuote. Nesting will not work as expected and I probably overlooked a ton of things, so expect breakages.

Caveat emptor This is more of an academic exercise to see if this could work, rather than code I would use in my real-world documents.

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}


\makeatletter
\protected\def\csq@oqmark@nogroup{%
  \global\advance\csq@qlevel\@ne
  \global\let\csq@oqmark\csq@qclose
  \global\let\csq@qclose@ii\csq@qclose@ii@nogroup
  \expandafter\csq@qopen
}

\let\csq@oqmark\csq@oqmark@nogroup

\let\csq@qclose@ii@orig\csq@qclose@ii

\def\csq@qclose@ii@nogroup#1{%
  \ifdim\lastkern=\csq@omitmarker
    \global\advance\csq@qlevel\m@ne
    \global\let\csq@oqmark\csq@oqmark@nogroup
    \global\let\csq@qclose@ii\csq@qclose@ii@orig
    #1%
  \else
    \csq@addkern@close
    \ifodd\csq@qlevel
      \csq@thequote@oclose
      \let\csq@kernchar@i\csq@thequote@oclose
    \else
      \csq@thequote@iclose
      \let\csq@kernchar@i\csq@thequote@iclose
    \fi
    \ifnum\csq@qlevel>\@ne
      \csq@setmarker@close
    \fi
    \global\advance\csq@qlevel\m@ne
    \global\let\csq@oqmark\csq@oqmark@nogroup
    \global\let\csq@qclose@ii\csq@qclose@ii@orig
    \ifblank{#1}{}{\expandafter#1}%
      \expandafter\def
      \expandafter\csq@kernchar@i
      \expandafter{\csq@kernchar@i}%
    \expandafter\csq@fixkern
  \fi}

\makeatother

\MakeOuterQuote{"}

\begin{document}
    \enquote{Bold text 1}

    "{\bfseries Bold text2}"

    \enquote{Bold text 1}

    "{\bfseries Wrong" text3}
\end{document}

„Bold text 1“//„Bold text2“//„Bold text 1“//„Wrong“ text3

If you ask me, I'd try to stick to using quotes only at the same grouping levels. If that is absolutely not possible for some reason, I'd use the manual \textooquote and \textcoquote in that case.

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}


\MakeOuterQuote{"}

\begin{document}
    \enquote{Bold text 1}

    "{\bfseries Bold text2}"

    \enquote{Bold text 1}

    \textooquote {\bfseries Wrong\textcoquote\ text3}
\end{document}
| improve this answer | |
  • Thx a lot. I stick for the very moment with the idea of doing the stuff manually, ie. \textooquote and \textcoquote - especially if you say your other solution might be fragile. The main reason why I cannot control the grouping is due to the fact of automatic transformation from HTML to TeX. What is valid in HTML might lead to complications in TeX, e.g. the above sample of quotes.I'm happy to have this kind of idea now. – LeO May 13 at 6:35
  • @LeO I see. Just curious: Does that sort of thing (quotes at different grouping levels) happen often in your texts? At least the \bfseries example looks really weird. And even for most other things I would have expected the group to either start before the quotation and span all of it or to be confined to inside the quotation. – moewe May 13 at 7:05
  • Well - honestly I don't know if it happens 'often' or not. Matter of fact is that the compile process shouldn't be terminated due a error which only a TeX expert could trace down to the root cause. So, if there would be some settings which would handle the whole situation in a graceful way - than this would be perfect. Otherwise I'll stick to the manual approach. – LeO May 13 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.