我有两个并排的盒子,minipage
里面的高度不同\fbox
,并且它们彼此居中
\documentclass{article}
\usepackage{fancybox}
\begin{document}
\noindent
\makebox[\textwidth]{%
\parbox{1.2\textwidth}{%
\setlength{\fboxsep}{10pt}%
\fbox{%
\begin{minipage}[c]{.53\textwidth}
text\\[8pt]
text\\[8pt]
text
\end{minipage}}%
\hfill
\fbox{%
\begin{minipage}[c]{.53\textwidth}
text \hrulefill\\
text \hrulefill\\
text \hrulefill
\end{minipage}}}}
\end{document}
但如果我minipage
在\shadowbox
\documentclass{article}
\usepackage{fancybox}
\begin{document}
\noindent
\makebox[\textwidth]{%
\parbox{1.2\textwidth}{%
\setlength{\fboxsep}{10pt}%
\shadowbox{%
\begin{minipage}[c]{.53\textwidth}
text\\[8pt]
text\\[8pt]
text
\end{minipage}}%
\hfill
\shadowbox{%
\begin{minipage}[c]{.53\textwidth}
text \hrulefill\\
text \hrulefill\\
text \hrulefill
\end{minipage}}}}
\end{document}
我怎样才能使小页面居中\shadowbox
?
答案1
您可以使用 重新居中框\raisebox
。我还稍微减小了宽度,为阴影留出了空间,因为 tex 警告框太满
\documentclass{article}
\usepackage{fancybox}
\begin{document}
\noindent
\makebox[\textwidth]{%
\parbox{1.2\textwidth}{%
\setlength{\fboxsep}{10pt}%
\fbox{%
\begin{minipage}[c]{.53\textwidth}
text\\[8pt]
text\\[8pt]
text
\end{minipage}}%
\hfill
\fbox{%
\begin{minipage}[c]{.53\textwidth}
text \hrulefill\\
text \hrulefill\\
text \hrulefill
\end{minipage}}}}
\bigskip
\noindent
\makebox[\textwidth]{%
\parbox{1.2\textwidth}{%
\setlength{\fboxsep}{10pt}%
\raisebox{-.5\totalheight}{\shadowbox{%
\begin{minipage}[c]{.52\textwidth}
text\\[8pt]
text\\[8pt]
text
\end{minipage}}}%
\hfill
\raisebox{-.5\totalheight}{\shadowbox{%
\begin{minipage}[c]{.52\textwidth}
text \hrulefill\\
text \hrulefill\\
text \hrulefill
\end{minipage}}}}}
\end{document}
答案2
您还可以使用adjustbox
包轻松获得任何所需的垂直对齐:
代码:
\documentclass{article}
\usepackage{fancybox}
\usepackage{adjustbox}
\begin{document}
\noindent
\makebox[\textwidth]{%
\parbox{1.2\textwidth}{%
\setlength{\fboxsep}{10pt}%
\adjustbox{valign=c}{\shadowbox{%
\begin{minipage}[c]{.52\textwidth}
text\\[8pt]
text\\[8pt]
text
\end{minipage}}}%
\hfill
\adjustbox{valign=c}{\shadowbox{%
\begin{minipage}[c]{.52\textwidth}
text \hrulefill\\
text \hrulefill\\
text \hrulefill
\end{minipage}}}}}
\end{document}