\documentclass{article}


\usepackage{amsmath,amsthm,amssymb}

\usepackage{xcolor}

\usepackage{colortbl}

\usepackage{listings}

\usepackage{tcolorbox}

\tcbuselibrary{most}

\usepackage{varwidth}


\begin{document}

\begin{tcolorbox}[sharp corners, text width = 8cm, boxrule=0pt, nobeforeafter, arc=0mm]  

\begin{lstlisting}[language={[LaTeX]TeX}]

$S=\sqrt[n]{\frac{a+b}{a-b}}$.

\end{lstlisting}

\end{tcolorbox}

\qquad $\Rightarrow$ \qquad

\tcbox[sharp corners, colframe=black, colback=white, width=(\linewidth-4pt)/3, boxrule=0.5pt, nobeforeafter, arc=0mm]

{$S=\sqrt[n]{\frac{a+b}{a-b}}$.}

\end{document}



请问如何将$S=\sqrt[n]{\frac{a+b}{a-b}}$.左移至背景色里面去,如何将箭头上移至中间位置。

4 回答4

4
<p>都用到 tcolorbox 了,为什么不充分利用 tcolorbox 的功能?而且代码还写两遍,就不怕左右不一致?下面给你一个有趣的解法。</p><pre class="brush:plain;toolbar:false">\documentclass{article} \usepackage{amsmath,amsthm,amssymb} \usepackage{tcolorbox} \tcbuselibrary{listings,xparse,skins} \usetikzlibrary{decorations.markings} \tcbset{enhanced,   common/.style ={sharp corners, boxrule=0pt, nobeforeafter, arc=0mm,     segmentation engine= path ,     segmentation style={%        decorate,        decoration={%           markings,          mark = between positions 0.5 and 0.9 step 0.45 with{%           \node{$\Rightarrow$};}        }     }   } } \DeclareTCBListing{Expbox}{O{}}{%     common,     listing side text, #1, } \begin{document} \begin{Expbox}[lefthand width=8cm]   $S=\sqrt[n]{\frac{a+b}{a-b}}$. \end{Expbox} \end{document}</pre><p><img src="/data/ueditor/php/upload/image/20190910/1568108754254796.png" title="1568108754254796.png" alt="TIM4.png"></p>
  • 谢谢!学习了!!! – ctuliu 2019-09-11 08:26 回复
2
<pre class="brush:plain;toolbar:false">\documentclass{article} \usepackage{mathtools} \usepackage{tcolorbox} \usepackage{listings} \tcbuselibrary{most} \begin{document} \begin{tcolorbox}[sharp corners,text width=0.8\linewidth,boxrule=0pt,nobeforeafter,arc=0mm]   \lstinline[language={[LaTeX]TeX}]|$S=\sqrt[n]{\frac{a+b}{a-b}}$| \qquad $\Rightarrow$ \qquad $S=\sqrt[n]{\dfrac{a+b}{a-b}}$ \end{tcolorbox} \end{document}</pre><p><img src="/data/ueditor/php/upload/image/20190910/1568103031439760.png" title="1568103031439760.png" alt="image.png"></p>
  • 非常感谢! – ctuliu 2019-09-11 08:26 回复
2
<pre class="brush:plain;toolbar:false">\documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{listings} \begin{document} \begin{tcblisting}{sharp corners, text width = 6.5cm, boxrule=0pt, nobeforeafter, arc=0mm,listing only,listing options={language={[LaTeX]TeX}},height=1.3cm} $S=\sqrt[n]{\frac{a+b}{a-b}}$. \end{tcblisting} \qquad \raisebox{0.5cm}{$\Rightarrow$} \qquad \tcbox[sharp corners, colframe=black, colback=white, width=(\linewidth-4pt)/3, boxrule=0.5pt, nobeforeafter, arc=0mm,height=1.3cm] {$S=\sqrt[n]{\frac{a+b}{a-b}}$.} \end{document}</pre><p>非要玩黑科技也是可行的</p><p><img src="/data/ueditor/php/upload/image/20190910/1568104071626590.png" title="1568104071626590.png" alt="QQ截图20190910162655.png"></p>
  • 你怎么知道我想要这样的结果呢?我确实想要这样的结果,棒棒的!!! – ctuliu 2019-09-11 08:27 回复
1
<p>\tcbset{colframe=blue!50!black,colback=white,</p><p>        listing engine=listings,</p><p>        fonttitle=\bfseries,nobeforeafter,center title}</p><p><br></p><p>\begin{tcblisting}{listing only,text width = 6cm,</p><p>listing options={language={[LaTeX]TeX}},height=1.3cm}</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>\end{tcblisting}</p><p>\qquad $\Rightarrow$ \qquad</p><p>%</p><p>\tcbox[width=0.25\textwidth]{%</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>}</p><p><br></p><p>\medskip<br></p><p><br></p><p>\tcbset{colframe=blue!50,colback=white,</p><p>        fonttitle=\bfseries,nobeforeafter}</p><p><br></p><p>\cprotect\tcbox{\verb|$S=\sqrt[n]{\frac{a+b}{a-b}}$.|}</p><p>\qquad $\Rightarrow$ \qquad</p><p>%</p><p>\tcbox[width=0.25\textwidth]{%</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>}</p><p><br></p><p>\medskip</p><p><br></p><p>\cprotect\tcbox{\lstinline|$S=\sqrt[n]{\frac{a+b}{a-b}}$.|}</p><p>\qquad \raisebox{2ex}{$\Rightarrow$} \qquad</p><p>%</p><p>\tcbox[width=0.25\textwidth]{%</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>}</p><p>\medskip</p><p><br></p><p>\begin{tcblisting}{sharp corners, text width = 6.5cm, boxrule=0pt, nobeforeafter, arc=0mm,listing only,listing options={language={[LaTeX]TeX}},height=1.3cm}</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>\end{tcblisting}</p><p><br></p><p>\begin{tcblisting}{listing options={language={[LaTeX]TeX}},</p><p>height=1.3cm,</p><p>listing side text,text width=13 }</p><p>$S=\sqrt[n]{\frac{a+b}{a-b}}$.</p><p>\end{tcblisting}</p><p><br></p><p style="line-height: 16px;"><img src="https://wenda.latexstudio.net/static/js/neweditor/dialogs/attachment/fileTypeImages/icon_pdf.gif"><a style="font-size:12px; color:#0066cc;" href="/data/ueditor/php/upload/file/20190911/1568166742665075.pdf" title="tcolorbox_mwe.pdf">tcolorbox_mwe.pdf</a></p><p><br></p>

你的回答

请登录后回答

你的回答将会帮助更多人,请务必认真回答问题。