我想使用 \fcolorbox 的多行。我尝试使用 //,但它不起作用。
代码:
\documentclass[12 pt, a4paper]{book}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
a4paper,
total={170 mm,257 mm},
left=20 mm,
top=20 mm,
}
\usepackage{amsmath,bm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{soul}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{calc}
\setlength{\parindent}{2em}
\newcommand{\wt}[2]{\underset{\substack{\textstyle\uparrow\\\hidewidth\mathstrut#2\hidewidth}}{#1}}
\definecolor{mygray}{gray}{0.6}
\begin{document}
\begin{flushright}
\underline{Ans}. $\Rightarrow$ \fboxrule=1pt \fcolorbox{black}{mygray}{
(a) 9's complement of $(5842)_{10}$ = $(4157)_{10}$.\\(b) 7's complement of $(6423)_{8}$ = $(1354)_{8}$.\\(c) 15's complement of $\mathrm{(A96D)}_{16}$ = $(5692)_{16}$}
\end{flushright}
\end{document}
有人可以帮我做到这一点吗?请提供不使用 tikz 包的解决方案。
答案1
与\fbox
内容一样,它是单行的,但你可以嵌套多行结构,例如\parbox
或这里我使用tabular
\documentclass[12 pt, a4paper]{book}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
a4paper,
total={170 mm,257 mm},
left=20 mm,
top=20 mm,
}
\usepackage{amsmath,bm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{soul}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{calc}
\setlength{\parindent}{2em}
\newcommand{\wt}[2]{\underset{\substack{\textstyle\uparrow\\\hidewidth\mathstrut#2\hidewidth}}{#1}}
\definecolor{mygray}{gray}{0.6}
\begin{document}
\begin{flushright}
\underline{Ans}. $\Rightarrow$ \fboxrule=1pt \fcolorbox{black}{mygray}{%
\begin{tabular}[t]{@{}l@{}}
(a) 9's complement of $(5842)_{10}$ = $(4157)_{10}$.\\
(b) 7's complement of $(6423)_{8}$ = $(1354)_{8}$.\\
(c) 15's complement of $\mathrm{(A96D)}_{16}$ = $(5692)_{16}$
\end{tabular}}
\end{flushright}
\end{document}