Latex:填充到一定宽度
我目前正在做类似的事情:
a\hfill{}b
将“a”放在页面的最左边,将“b”放在页面的最右边。然而,我希望“b”正好是一半。是否有一个 \hfill 等效项,我可以说 \hfill{0.5\textwidth}
? 我不知道“a”的宽度。
显然,我可以使用表格,或者可能是小型页面,但是这里的其余代码非常复杂,所以我不想弄乱它。
编辑:
a
和 b
都是带有 lstinputlistings 的子浮点(子图)。
I'm currently doing something like:
a\hfill{}b
which puts 'a' at the far left, and 'b' at the far right of the page. However, I'd like 'b' to be exactly half way. Is there a \hfill equivalent where I can say \hfill{0.5\textwidth}
?
I don't know the width of 'a'.
Obviously, I could use tabular, or maybe minipage, but the rest of the code here is pretty complicated, so I'd rather not mess with it.
Edit:
a
and b
are both subfloats (subfigure) with lstinputlistings in them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
注意:如果 a 的宽度小于 0.5\textwidth,则此方法有效,因此 multicol 答案可能更合理
NB: this works if width of a is less than 0.5\textwidth so the multicol answer is probably more reasonable
您可以尝试将
columnsep
设置为 0 的multicol
环境。顺便说一下,还有一种方法可以通过
\ settowidth
和\settoheight
。You could try a
multicol
environment withcolumnsep
set to 0.There is, by the way, also a way to measure the size of a rendered part, through
\settowidth
and\settoheight
.尝试将 \hfill 替换为 \hskip 0pt plus 1fill,你可以做一些令人惊奇的事情。例如,
Try replacing \hfill to \hskip 0pt plus 1fill and you can do amazing things. For example,