是否可以使用 fancybox 创建椭圆形和彩色盒子?

是否可以使用 fancybox 创建椭圆形和彩色盒子?

我希望我的红框是椭圆形。这是我的代码:

\documentclass[12pt,a4paper]{article}

\usepackage[latin1]{inputenc} 
\usepackage[T1]{fontenc}      
\usepackage[french]{babel}
\usepackage{amsmath,amssymb}
\usepackage{psfrag}
\usepackage{fancybox}
\usepackage{pgfplots}

\begin{document}

$$\ddot{x}+\colorbox{red!10}{$\frac{\omega_0}{Q}$}\dot{x}+\omega_0^2 x=0$$

\end{document}

答案1

与Bernard的回答类似,\tcboxmath来自tcolorbox

\documentclass[12pt,a4paper, french]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsmath,amssymb}
\usepackage[table]{xcolor}
\usepackage[most]{tcolorbox}

\tcbset{%
  highlightstyle/.style={enhanced,colback=red!40,boxsep=0pt,frame hidden}
}


\begin{document}

\[ \ddot{x}+\tcboxmath[highlightstyle,sharp corners]{\frac{\omega_0}{Q}}\dot{x}+\omega_0^2 x=0 \]

\[ \ddot{x}+\tcboxmath[highlightstyle,auto outer arc, arc=15pt]{\frac{\omega_0}{Q}}\dot{x}+\omega_0^2 x=0 \]

\[ \ddot{x}+\tcboxmath[highlightstyle,octogon arc,arc is angular]{\frac{\omega_0}{Q}}\dot{x}+\omega_0^2 x=0 \]

\end{document} 

在此处输入图片描述

答案2

这里有两种方法pstricks

除了注释之外:语言选项应该与文档类一起加载,因为babel 3.9,为了确保语言相关包知道文档的主要语言。此外,您不应该使用构造$$ ... $$,它是纯 TeX,始终首选\[ ... \]

\documentclass[12pt,a4paper, french]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsmath,amssymb}
\usepackage[table]{xcolor}
\usepackage{psfrag}
\usepackage{fancybox}
\usepackage{pst-node}
\usepackage{auto-pst-pdf} %% to compile with pdflatex -shell-escape under TeX Live or MacTeX, pdflatex --enable-write18 under MiKTeX
\usepackage{pgfplots}

\begin{document}

\[ \ddot{x}+\colorbox{red!10}{$\dfrac{\omega_0}{Q}$}\dot{x}+\omega_0^2 x=0 \]

\[ \ddot{x}+\raisebox{\dimexpr-0.5\height +0.25ex}{\psovalbox*[fillcolor = red!20]{$ \dfrac{\omega_0}{Q} $}}\dot{x}+\omega_0^2 x=0 \]

\[ \ddot{x}+\raisebox{\dimexpr-0.5\height +0.25ex}{\psframebox*[fillcolor = red!30, framearc =.6]{$ \dfrac{\omega_0}{Q} $}}\dot{x}+\omega_0^2 x=0 \]

\end{document} 

在此处输入图片描述

相关内容