我想使用tcolorbox
创建on line
等高(内联)框equal height group
。但这些框位于不同的高度。
梅威瑟:
\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}
\usepackage[many]{tcolorbox}
\tcbset{common/.style={
enhanced, size=small, nobeforeafter, on line, drop fuzzy shadow
}
}
\newtcbox{\databoxcenter}[1]{
common, leftrule=0pt, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxleft}[1]{
common, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxright}[1]{
common, leftrule=0pt, equal height group=#1
}
\begin{document}
The following boxes are positioned as if \texttt{equal height group} is not in effect:
\databoxleft{addr}{2/17,} \databoxcenter{addr}{Hamlet 5,} \databoxright{addr}{China}. The heights do seem equal, though.
\end{document}
答案1
一种可能的方法是调整该baseline
值,即baseline=2mm
看起来是一个合适的值。
\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}
\usepackage[many]{tcolorbox}
\tcbset{common/.style={
box align=base,
enhanced jigsaw, size=small,on line,baseline=2mm,drop fuzzy shadow
}
}
\newtcbox{\databoxcenter}[1]{
common,leftrule=0pt, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxleft}[1]{
common, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxright}[1]{
common, leftrule=0pt, equal height group=#1
}
\begin{document}
The following boxes are positioned as if \texttt{equal height group} is not in effect:
\databoxleft{addr}{2/17,} \databoxcenter{addr}{Hamlet,5} \databoxright{addr}{China}. The heights do seem equal, though.
\end{document}
答案2
另一个解决方案是强制所有框的高度和深度相等。我已经添加了before upper=\strut
样式common
定义。
\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}
\usepackage[many]{tcolorbox}
\tcbset{common/.style={
enhanced, size=small, nobeforeafter, on line, drop fuzzy shadow,
before upper=\strut
}
}
\newtcbox{\databoxcenter}[1]{
common, leftrule=0pt, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxleft}[1]{
common, rightrule=0pt, equal height group=#1
}
\newtcbox{\databoxright}[1]{
common, leftrule=0pt, equal height group=#1
}
\begin{document}
The following boxes are positioned as if \texttt{equal height group} is not in effect:
\databoxleft{addr}{2/17,} \databoxcenter{addr}{Hamlet 5,} \databoxright{addr}{China}. The heights do seem equal, though.
\end{document}