Hacer transparente el fondo de la caja.

Hacer transparente el fondo de la caja.

Como en mi documento tengo que escribir muchas matemáticas en cuadros de colores, me gustaría evitar escribir $ dentro de cada cuadro. ¿Hay alguna manera de definir newtcboxen modo matemático?

Lo intenté \newtcbox{\mywbox}[1]{<options>}{$\displaystyle #1$}pero no funciona.

Este es mi código de látex:

\usepackage{tcolorbox}
\newtcbox{\mywbox}{on line,colback=white,colframe=black,size=fbox,arc=3pt,boxrule=0.8pt}

\begin{document}
\obeylines

This \mywbox{$3x$} is in line math.
This $$y=\mywbox{$-5x$}-5+6$$ is not in line math.

\end{document}

ingrese la descripción de la imagen aquí

Leí sobre \tcboxmathy \tcbhighmathen el manual oficial de tcolorbox, pero no entiendo cómo definirlos simplemente como newtcbox y si son lo que necesito.

Respuesta1

yo diría

\newtcbox{\mywboxtext}{on line,colback=white,colframe=black,size=fbox,arc=3pt,boxrule=0.8pt}
\newcommand{\mywboxmath}[1]{\mywboxtext{$#1$}}

Tu ejemplo puede convertirse

\documentclass{article}
\usepackage{tcolorbox}

\newtcbox{\mywboxtext}{on line,colback=white,colframe=black,size=fbox,arc=3pt,boxrule=0.8pt}
\newcommand{\mywboxmath}[1]{\mywboxtext{$#1$}}

\begin{document}

This \mywboxmath{3x} is in line math and this
\[
y=\mywboxmath{-5x}-5+6
\]
is display math.

\end{document}

ingrese la descripción de la imagen aquí

Cambia los nombres a tu gusto.

Evitar $$en LaTeX(y por supuesto también \obeylines).

Si necesita que los cuadros se comporten en subíndices o superíndices, cambie el código a

\documentclass{article}
\usepackage{tcolorbox}

\newtcbox{\mywboxtext}{on line,colback=white,colframe=black,size=fbox,arc=3pt,boxrule=0.8pt}

\makeatletter
\newcommand{\mywboxmath}[1]{\mathpalette\mywboxmath@do{#1}}
\newcommand{\mywboxmath@do}[2]{\mywboxtext{$\m@th#1#2$}}
\makeatother

\begin{document}

This $\mywboxmath{3x}$ is in line math and this
\[
y_{\mywboxmath{0}}=\mywboxmath{-5x}-5+6
\]
is display math.

\end{document}

Tenga en cuenta que en este caso necesita que \mywboxmathesté en modo matemático.

Respuesta2

Puedes hacer esto usando \tcboxmathdesde la theoremsbiblioteca de tcolorbox:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\newcommand*{\mywbox}{%
  \tcboxmath[colback=white, colframe=black, size=fbox, arc=3pt, boxrule=0.8pt]%
}

\begin{document}

This \mywbox{3x} is in line math.
This
\[ y = \mywbox{-5x} - 5 + 6 \]
is not in line math.

\end{document}

Captura de pantalla

Es posible que también desees abstraer un poco las cosas usando un estilo, para poder aplicarlo a otros cuadros si surge la necesidad:

\documentclass{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\tcbset{my math box/.style={
          colback=white, colframe=black, size=fbox, arc=3pt, boxrule=0.8pt}
}

\newcommand*{\mywbox}{\tcboxmath[my math box]}

\begin{document}

This \mywbox{3x} is in line math.
This
\[ y = \mywbox{-5x} - 5 + 6 \]
is not in line math.

\end{document}

Hacer transparente el fondo de la caja.

Esto se puede hacer usando /tcb/opacitybackuna piel usando unrompecabezasmotor de bastidor, como standard jigsawo enhanced jigsaw.

\documentclass[fleqn]{article}
\usepackage{tcolorbox}
\tcbuselibrary{theorems}

\tcbset{
  my math box/.style={
    standard jigsaw,   % useful for 'opacityback' and 'opacityframe'
    colback=green!20, colframe=black, size=fbox, arc=3pt, boxrule=0.8pt,
    opacityback=0.6,
  }
}

\newcommand*{\mywbox}{\tcboxmath[my math box]}

\begin{document}

This \makebox[0pt]{%
  \raisebox{-0.5\height}[0pt][0pt]{\hspace{1cm}\includegraphics{example-image-duck}}%
  }%
\mywbox{3x} is in line math.
This
\[ y = \mywbox{-5x} - 5 + 6 \]
is not in line math.

\end{document}

ingrese la descripción de la imagen aquí

información relacionada