\hbox \mbox 区别......它们有什么作用?

\hbox \mbox 区别......它们有什么作用?

\hbox和有什么区别\mbox

这些命令的目的是什么?

我无法从我的代码中看出它们的作用,没有任何文字解释......

答案1

正如评论中提到的那样,\mbox在使用之前离开垂直模式\hbox。但问题似乎也包含“什么是盒子”?

因此,这个答案试图回答这两个问题。前三个示例比较了带框的文本和非带框的文本。最后一个示例解决了何时离开垂直模式会产生影响。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\parindent0pt
\begin{document}

Mbox Meaning: \meaning\mbox

\hrulefill

\textbf{BOXES ARE UNBREAKABLE}

This is a texting piece of text. This is a texting piece of text.
This is a texting piece of text.

\mbox{This is a texting piece of text. This is a texting piece of text.
This is a texting piece of text.}

\hrulefill

\textbf{BOXES ARE UNHYPHENATABLE}

This is a texting piece of text. This is texting piece of text.
This is an hyphenatable piece of text.

This is a texting piece of text. This is texting piece of text.
This is an \mbox{hyphenatable} piece of text.

\hrulefill

\textbf{BOXES ARE UNSTRETCHABLE}

This is a texting piece of text. This is the texting piece of text.
This is a texting piece of text.

This is a texting \mbox{piece of text. This is the texting piece of text.}
This is a texting piece of text.

\hrulefill

\textbf{WHEN LEAVING VERTICAL MODE MAKES A DIFFERENCE}
\parskip 1ex

blah

\mbox{Regular line space with mbox}

\hbox{Irregular line space with hbox}

blah
\end{document}

在此处输入图片描述

相关内容