Table of contents

Boxes and Comments

It is used when the user needs an imaginary box that can be treated as a single large character to typeset the text. In this article, you will learn about various boxes, comments and footnotes.

Boxes

A single – line box can be created using the command \text or \makebox and a multi – line command can be created using the command \parbox or a minipage environment. There are many types of boxes and some of them are discussed below:

1. Line boxes

The command \text creates a line box that creates a line box and is used to typeset the argument without breaking lines and is taken as a single character. This makes the argument extend into the margin. For example, the command \text{speaker} treats the seven characters of the word as one. It allows the user to use this phrase in the argument in a formula and prevents The command \mbox is the short form of \makebox. This argument also prevents from breaking an argument but keeps the size of the subscript and superscript same. The full command is written as \makebox[width][alignment]{text} where, The optional width argument, width, can use four length commands: \height is used to give the height of the box above baseline, \depth gives the depth of the box below baseline, \totalheight is the sum of \height and \depth and \width is used to determine the width of the box.


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	\makebox{Text Box.}End\\
	\makebox[2in][l]{Text Box.}End\\
	\makebox[2in]{Text Box.}End\\
	\makebox[2in][r]{Text Box.}End\\
	\makebox[2in][s]{Text Box.}End
	\end{document}

line-LaTeX-img
  • Width is an optional command that gives the width of the box and if omitted, the box is as wide as necessary according to the contents. It can be specified in inches.

  • Alignment is an optional command. The is placed at the center by default, l sets it to flush left, r sets it to flush right and s stretches the length to the full length of the box if it has blank spaces.

  • Text is the text inside the box.

The command \rlap is a variant of the \makebox command whose functionality is to make a box and pretend that it has zero width.

2. Frame Boxes

The command \fbox or \framebox generates the frame boxes. This command is used for a single line box as the boxes cannot be broken, hence for a box having more than one line we should use the command \parabox or the minipage environment.


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	\framebox[1.1\width]{This fits inside the frame} \par
	\framebox[0.8\width][r]{This is too wide for the frame} \par
	\framebox[1cm][l]{This does not fit at all}
	\end{document}

Output of the above code

line-LaTeX-img

This command works exactly like the \makebox command except, that it makes the frame around the box.

3. Paragraph Boxes

A paragraph box is specially used when the user is working within a tabular environment. It works like a paragraph whose width is given by the user. The command \parbox typesets the content which is given in its second argument and its first argument gives the width of the box. The box that is generated is handled as a single character


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	\parbox{\textwidth}{
		Some very long text\\
		that would not be allowed\\
		in a frame box.}
	\end{document}

Output of the above code

line-LaTeX-img

The command \parbox creates a character that is placed on the line so that its vertical center is aligned with the center of the line. The full syntax of the command is \parbox[alignment][height][[inner-alignment]{width}{text}. The inner alignment is the vertical equivalent of the alignment of the \makebox command. It determines the position of the text. When the inner alignment argument is not given, then it is taken as an alignment.

4. Solid Boxes

A solid box is generated using the command \rule. The first argument gives the width and the second argument is for the height. The positioning of the symbol is done using the first optional argument. Solid boxes having zero width are known as struts. Standard struts can be added using the command \strut or \mathstrut .


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	\fbox{ab}
	\fbox{\strut ab}
	\fbox{$\mathstrut$ab}
	\end{document}

Output of the above code

line-LaTeX-img

5. Fine Tuning Boxes

The command \raisebox {displacement}{text} typesets text in a box with a vertical displacement. If displacement is positive then the box is raised, otherwise the box is lowered.


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	abc\raisebox{.5ex}{def}\raisebox{-.5ex}{ghi}
	\end{document}

Output of the above code

line-LaTeX-img

Comments

A comment is a line that is supposed to be ignored. It is used for the user to make the commands understandable and they are not shown in the output. The symbol % tells the LaTeX when to ignore the rest of the line.


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\begin{document}
	This is supposed to show
	% This is not supposed to show 
	\end{document}

Output of the above code

line-LaTeX-img

The multi – line comments are written using the package verbatim. An example is shown below:


	\documentclass{article}
	\usepackage[utf8]{inputenc}
	\usepackage{verbatim}
	\begin{document}
	This is supposed to show
	\begin{comment}
	this
	is
	not
	supposed
	to
	show
	\end{comment}
	\end{document}

Output of the above code

line-LaTeX-img

Footnotes

The text of the footnote is typed in the argument of the command \footnote. A footnote can also be added to the title of the article marked by *.

Don't want to invest time in typesetting documents manually?

Convert Word to LaTeX now
Copied to Clipboard!