我需要框出方程的一部分,但我需要框的一侧是开放的。在下面的 MWE 中,我需要方程的左侧部分没有框的右侧框架,方程的右侧部分没有框的左侧框架。
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
This is my equation $\boxed{q_1^{\ast}}=\dfrac{26-2\cdot 1 -4\cdot 2}{2\cdot 1}=\boxed{8}$
\end{document}
答案1
以下 MWE 提供\lboxed
和,\rboxed
它们是截断的。从技术上讲,这与仅删除了右/左的部分\fbox
相同(的定义取自\fbox
\vrule
\fbox
latex.ltx
)。它还提供\llboxed
和,\rrboxed
它们是array
样式框,其中所需的边剥离了垂直规则。
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand{\lboxed}[1]{\begin{array}{|l}\hline#1\\\hline\end{array}}
\newcommand{\rboxed}[1]{\begin{array}{r|}\hline#1\\\hline\end{array}}
\makeatletter
\newcommand{\llboxed}[1]{{%
\let\@frameb@x\l@frameb@x\fbox{#1}%
}}
\newcommand{\rrboxed}[1]{{%
\let\@frameb@x\r@frameb@x\fbox{#1}%
}}
\def\l@frameb@x#1{%
\@tempdima\fboxrule
\advance\@tempdima\fboxsep
\advance\@tempdima\dp\@tempboxa
\hbox{%
\lower\@tempdima\hbox{%
\vbox{%
\hrule\@height\fboxrule
\hbox{%
\vrule\@width\fboxrule
#1%
\vbox{%
\vskip\fboxsep
\box\@tempboxa
\vskip\fboxsep}%
#1%
%\vrule\@width\fboxrule% Right \vrule removed
}%
\hrule\@height\fboxrule}%
}%
}%
}
\def\r@frameb@x#1{%
\@tempdima\fboxrule
\advance\@tempdima\fboxsep
\advance\@tempdima\dp\@tempboxa
\hbox{%
\lower\@tempdima\hbox{%
\vbox{%
\hrule\@height\fboxrule
\hbox{%
%\vrule\@width\fboxrule% Left \vrule removed
#1%
\vbox{%
\vskip\fboxsep
\box\@tempboxa
\vskip\fboxsep}%
#1%
\vrule\@width\fboxrule}%
\hrule\@height\fboxrule}%
}%
}%
}
\makeatother
\begin{document}
This is my equation $\boxed{q_1^{\ast}}=\dfrac{26-2\cdot 1 -4\cdot 2}{2\cdot 1}=\boxed{8}$
This is my equation $\rboxed{q_1^{\ast}}=\dfrac{26-2\cdot 1 -4\cdot 2}{2\cdot 1}=\lboxed{8}$
This is my equation $\rrboxed{$q_1^{\ast}$}=\dfrac{26-2\cdot 1 -4\cdot 2}{2\cdot 1}=\llboxed{$8$}$
\end{document}