如何在 LaTeX 中对内容进行装箱,使所有框都在同一行且高度相同?
我需要用方框包围的按键文本来表示计算器按键。我试图只按一下按键(没有盒子)就可以逃脱惩罚,但我因此被扣分,因为我的评估员似乎有点学究气。
无论如何,一些研究发现了 \boxit 和 \fbox 之类的东西。
我对它们都进行了尝试,但 \boxit 产生的结果与 \fbox 几乎相同。 问题在于框的高度和基线随其包含的字形而变化。
以下面的例子表示按 5、乘、x;
\documentclass{article}
\usepackage{fullpage}
\begin{document}
\fbox{5} \fbox{$\times$} \fbox{$x$}
\end{document}
这会在内容周围生成框,但它们位于不同的基线上,并且高度也不同。
鉴于到目前为止我所看到的 LaTeX,我想说这绝对是可能的,但 CTAN、新闻组和谷歌到目前为止还没有发现任何有用的东西。
有什么提示吗?
I need to represent calculator key presses by the text for the keys to press surrounded by a box. I tried to get away with just the bare key presses (no box) but I got marked down for it because it would appear my assessor is a bit of a pedant.
Anyway, a bit of research turned up the likes of \boxit and \fbox.
I gave them both a go but \boxit produces nigh on identical results to \fbox.
The problem is that the height and baseline of the box varies with the glyphs it contains.
Take the following example that represents pressing 5, multiply, x;
\documentclass{article}
\usepackage{fullpage}
\begin{document}
\fbox{5} \fbox{$\times$} \fbox{$x$}
\end{document}
This generates boxes around the content but they're on different baselines and they're all different heights.
Given what I've seen of LaTeX thus far I'd say this is definitely possible but CTAN, news groups and google have turned up nothing useful thus far.
Any hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
\strut
使高度相同。或设置盒子的任意高度和深度:
Using
\strut
to make the same height.or set any height and depth of your box:
这看起来很接近您想要做的事情。
您可能想要创建一个新命令来创建密钥,以避免重复自己:
我确实找到了一个名为 key Strike.sty,但这对于您想要做的事情来说可能有点过分了。
This looks close to what you are trying to do.
You may want to create a new command to create the keys, to avoid repeating yourself:
I did find a package called keystroke.sty, but it may be overkill for what you're trying to do.
我能想到的最好的答案是:
是的。
The best I can come up with:
Yegh.