3

I need a macro that expands an argument into the string { "argument"}. The following macro seems to do the trick:

\newcommand{\myquote}[1]{\{ "{#1}"\}}

This macro produces for the input xyzzy{\myquote{fubar}} the output xyzzy{ ”fubar”} which is what I expect.

However, the macro seizes to work properly once I add the package ngerman to my document by writing in the header \usepackage{ngerman}. Now the input xyzzy{\myquote{fubar}} no longer produces the expected output, but instead results in an error when running latex:

! ngerman: The command "fubar is undefined.

I have tried to modify the macro with

\newcommand{\myquote}[1]{\{ \noexpand"{#1}\noexpand"\}}

This gets rid of the error, but the quotes " are not displayed at all anymore. The observed output becomes xyzzy{ fubar} instead of the expected one (the quotes are simply missing).

How do I need to write the macro that produces the expected output even in the presence of the ngerman package?

[Edit] Clarification: The macro is needed as a marker for a post-processor. Thus, there must not be typographical quotes, but regular double quotes.[/Edit]

  • 1
    The ngerman package is obsolete, use \usepackage[ngerman]{babel} instead. This will also solve the error. – Qrrbrbirlbel Jun 25 '13 at 13:15
  • Use the csquotes package. – Daniel Jun 25 '13 at 13:15
  • What about \newcommand{\myquote}[1]{\{ ``#1''\}}? – Sigur Jun 25 '13 at 13:28
  • @Qrrbrbirlbel Using \usepackage[ngerman]{babel} indeed solves the issue. csquotes is not needed. – user8472 Jun 25 '13 at 13:31
  • @user8472: However, with csquotes you gain independence from the loaded font as well as other language packages that may turn " into an active character. – Daniel Jun 25 '13 at 13:34
4

The ngerman package is obsolete and should be replaced with the babel package loaded with the ngerman option.

As the default font Computer Modern creates still not the up-quotes " but the English closing quotes you should us the T1 font encoding (you should use it anyway for a German text) and the lmodern fonts (or whatever font you prefer).

Code

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{lmodern}% or libertine …
\usepackage[T1]{fontenc}
\newcommand{\myquote}[1]{\{"{#1}"\}}
\begin{document}
\myquote{fubar}
\end{document}

Output

enter image description here

enter image description here

2

The excellent csquotes package provides a convenient interface to all kinds of quotation problems. Main purpose is typographically correct quotation, but it also provides commands to directly access all kinds of quotation characters.

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

\newcommand{\myquote}[1]{\{\textquotedblleft{#1}\textquotedblleft\}}

\begin{document}

  Text in \enquote{typographischen Anführungsstrichen} oder \myquote{anderen Anführungsstrichen}.

\end{document}

enter image description here

  • If I understand the OP correctly he doesn’t want typographical correct quotes but " (and all enclosed in { and }). – Qrrbrbirlbel Jun 25 '13 at 13:21
  • Yes, I need the regular quote character ". The { and } are easy to add (I have just added them for completeness to my question). – user8472 Jun 25 '13 at 13:24
  • @user8472: See updated answer – Daniel Jun 25 '13 at 13:30

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.