1

I'd like to enclose some content in quotation marks in math mode. The content is text, so I put it as a parameter to \text from amsmath.

S = \text{“some text”}

But the quotation marks aren't part of the content of S, so I'd like to not include them in the \text tag. Ideally, the quotation marks would function as delimiters like brackets, so it would be this:

S = \left“ \text{some text} \right”

That would allow also parity checks, using them with things other than text, and maybe automatic sizing and positioning.

How can I do something like that? I mean defining custom bracket-like delimiters or an other tool for setting text strings in math mode.

8
  • 3
    I'm not sure what kind of resizing you have in mind.
    – egreg
    Sep 21 '21 at 10:38
  • 2
    quotation marks are normally considered text not math so \text{“some text”} looks like the expected markup to me. \left\right looks wrong, you could use \mathopen \mathclose` like non-stretchy () but text seems more natural. You can only use \left with characters that are set up in the font as variable sized, and that won't be the case with delimiters. Sep 21 '21 at 10:42
  • I think it’s not unreasonable to ask for automatic positioning when we are dealing with large math structures. Obviously for the closing quotation marks, you can do {...}''. I’m not quite sure what to do about the opening marks. Maybe rotating \prime and doing \vphantom{...}^{\rotatedprime\rotatedprime}{...}''?
    – Gaussler
    Sep 21 '21 at 10:46
  • @Gaussler but {...}'' in math will make a double superscript prime not a close quote, they don't really look that similar. Sep 21 '21 at 10:53
  • @DavidCarlisle Then suggest a way to fix this. :-)
    – Gaussler
    Sep 21 '21 at 10:59
1

New Solution

I defined a command \mathquote{...} that inserts quotation marks depending on the vertical size of its content.

Code

\documentclass{article}

\usepackage{amsmath}

\newlength{\mqheight}
\newlength{\mqnormalheight}
\settoheight{\mqnormalheight}{\hbox{gM}}%
\newcommand{\mathquote}[1]{%
    \settoheight{\mqheight}{\hbox{\ensuremath{#1}}}%
    \addtolength{\mqheight}{-\mqnormalheight}%
    \text{\raisebox{\the\mqheight}{``}}%
    #1%
    \text{\raisebox{\the\mqheight}{''}}%
    %\qquad\text{(raise quotes by: \the\mqheight)}% (info)
}

\begin{document}

\begin{align}
    a &= \mathquote{\sum\limits_{i=1}^N i}\\
    b &= \mathquote{\int\limits_{a}^{b} x^2 dx}\\
    c &= \mathquote{\left(\sum\limits_{i=1}^n i\right) + x}\\
    d &= \mathquote{g + B}
\end{align}

\end{document}

Result

enter image description here

Old Solution

Your question is not completely clear to me, but to get automatic parity check you can use the package csquotes and its command \enquote{...}, which is also useful for normal text and different languages.

In this case (language = default = english) the result is the same as typing and .

Code

\documentclass{article}

\usepackage{amsmath}
\usepackage{csquotes}

\begin{document}

\begin{align}
    a &= \text{“some text”}\\
    b &= \text{\enquote{some text}}
\end{align}

\end{document}

Result

enter image description here

4
  • \enquote doesn't work in math mode, and I want to have the quotation marks outside of the \text tag because they aren't a part of the text string. Also, ideally, I'd like to be able to use the quotes with things other than text strings, but that isn't necessary.
    – matj1
    Oct 1 '21 at 17:42
  • I don't understand the need why the quotes should not be inside the text command. How would the result be different if the quotes were outside? This should be explained in more detail in the question, possibly with a concrete example and an image of the desired result.
    – dexteritas
    Oct 1 '21 at 17:48
  • @dexteritas -- the OP says (in a comment) that something like an integral sign might be wanted inside the quoted material, and the (relatively low) vertical position of the quotation marks would look silly in that case. Unfortunately, I don't have any good suggestions for raising them to an appropriate height. Oct 1 '21 at 21:08
  • @barbarabeeton Thanks for the explanation. I added a new solution.
    – dexteritas
    Oct 2 '21 at 9:39

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.