0

I am attempting to define a command \ideal that will wrap its argument in bold parentheses. Here is my attempt: \newcommand{\ideal}[1]{\boldsymbol{\left(\right.} #1 \boldsymbol{\left.\right)}}

This compiles correctly visually (on overleaf) but produces this error:

You need to enclose all mathematical expressions and symbols with special markers. These special markers create a ‘math mode’. Use $...$ for inline math mode, and [...] or one of the mathematical environments (e.g. equation) for display math mode. This applies to symbols such as subscripts ( _ ), integrals ( \int ), Greek letters ( \alpha, \beta, \delta ) and modifiers (\vec{x}, \tilde{x} ).

If I use too many of them in the same document, it will not compile at all.

7
  • Can you please post a minimal example showing how you want to use your macro? If you really want to wrap text in it (not parts of equations) then using \boldsymbol is the wrong approach (as well as using \left and \right), instead you could use something like this: \newcommand\ideal[1]{\textbf{(}#1\textbf{)}}. As it is currently defined the \left and \right calls don't do anything useful anyway
    – Skillmon
    Nov 5, 2021 at 18:34
  • I was using \left and \right so that the parentheses would resize. Nov 5, 2021 at 18:56
  • But they don't if the material you want them to enclose isn't between the \left and \right. What you're doing is using two empty pairs of \left and \right. This way it won't resize to anything.
    – Skillmon
    Nov 5, 2021 at 18:57
  • I did not realize this... Thank you! Nov 5, 2021 at 19:06
  • note that you have not provided any example that would produce an error an dthe text that youquote is not a tex error message, it may be some help text from an editor. So it is rather hard to guess what you have actually done wrong (although as Skillmon says your definition is a bit strange but should not generate errors) Nov 5, 2021 at 19:18

1 Answer 1

1

You can use the bm package

enter image description here

\documentclass{article}

\usepackage{bm}

\newcommand\ideal[1]{\bm(#1\bm)}

\begin{document}

$(x) +\ideal{x}$

\end{document}

4
  • This looks the way I want, but now my command \newcommand{\NN}[1]{\mathscr{N}\left(#1\right)} is ignored and it prints a nonscript N. Nov 5, 2021 at 18:55
  • @KaceyReidy that is completely unrelated though. \mathscr is not a standard command you must have loaded some package to define it perhaps the euscript package, but there are several script font package. Nothing here is related to script fonts. Nov 5, 2021 at 19:12
  • I have realized the error with changing the ideal command: it makes it so that I load too many math alphabets. So, I need to fix the ideal command without using bm Nov 5, 2021 at 20:19
  • @KaceyReidy you could use \boldsymbol instead (but \bm gives the correct spacing) the bm package shouldn't make you run out of alphabets, did you load it last as it documents? Nov 5, 2021 at 20:37

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.