# Tag Info

392

The primitive TeX commands for building boxes are \hbox, horizontal box \vbox, vertical box with reference point at the last line inside it \vtop, vertical box with reference point at the first line inside it \vcenter, vertical box with reference point in the middle (almost) Their usage in LaTeX documents is not encouraged, but when programming some macro ...

132

Well, I see there are a lot of answers already, and they work, however I thought I'd give more detail: As above, you can use \usepackage[hidelinks]{hyperref} or \hypersetup{hidelinks} However, if your problem is with the ugly green boarder there are very nice ways to remove that, without making it unclear what is a hyperlink. I like \hypersetup{ ...

112

It is worth noting that TeX doesn't make the value judgements here. The user, or more likely, the class file on behalf of the user, has set constraints on the amount by which boxes may overflow, the amount of stretching allowed on short pages etc. TeX only warns if these user-set constraints are exceeded. So if you are setting difficult material with lots ...

64

\hbox is a TeX primitive and \mbox is a LaTeX macro defined via \long\def\mbox#1{\leavevmode\hbox{#1}} The \leavevmode means that it starts a paragraph, compare: \hbox{one} \hbox{two} three with \mbox{one} \mbox{two} three The other difference is that the argument is parsed as a normal macro argument, so for example \mbox a works and is identical to \...

61

Here's a list of other possible solutions A solution that admits page breaks using mdframed: \documentclass{article} \usepackage[framemethod=tikz]{mdframed} \usepackage{lipsum} \begin{document} \lipsum[4] \begin{mdframed}[hidealllines=true,backgroundcolor=blue!20] \lipsum[2] \end{mdframed} \lipsum[4] \end{document} The environments provided by the ...

60

Try the tcolorbox package. A little example \documentclass{article} \usepackage{tcolorbox} \usepackage{lipsum} \begin{document} \begin{tcolorbox}[colback=green!5,colframe=green!40!black,title=A nice heading] \lipsum[2] \end{tcolorbox} \end{document} The mdframed package can also be an option: \documentclass{article} \usepackage{xcolor} \usepackage[...

57

You can use \fbox{...} to put a frame around a \parbox{...} containing your text. Here's an example document. Note the \noindent that prevents the box from being shifted to the right. \documentclass{article} \begin{document} \noindent\fbox{% \parbox{\textwidth}{% The quick brown fox jumps right over the lazy dog. the quick brown fox jumps ...

57

\sbox is a short form of \savebox in the same way that \mbox is a short form of \makebox for the common case where you do not need to specify any lengths and want the natural size of the box. \setbox is the underlying TeX primitive so it does not read its arguments as a normal macro (like the comparison between \hbox and \mbox) and it is not safe to use with ...

55

just use \centering inside the box. \parbox{2cm}{\centering one two three four five six} I assume you are using this package, so with some limitations you can do this: \documentclass{article} \usepackage{pbox} \begin{document} \parbox{2cm}{\centering one two three four five six eight nine ten aaaaaa\\ bbb} \bigskip \pbox{5cm}{\relax\ifvmode\...

53

Yes, you should definitely take care of them. Overfull \hbox messages tell you that some line sticks out over the right margin; Underfull \hbox messages tell you that some line is poorly typeset (or that you've improperly used \\ to leave a vertical space (for example, typing two \\ in a row); Underfull \vbox messages usually tell you that a page is poorly ...

52

In none of the presented cases you should use \mbox. Phone numbers should use a kern, such as 123\,456\,7890 Things such as p.~210~sq.\@ should use a tie (note the \@ in order not to make the period as a sentence ending one) Names should use ~: Jean de~La~Fontaine (you may want to remove the first ~ if line breaking becomes otherwise unfeasible) Space ...

50

For the top use the [t] specification. For the bottom you can reinstate after the minipage the depth of the last row \documentclass{article} \usepackage{lipsum} \newcommand\Text{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, ...

50

In All(TeX), like in html/css everything is a box. When Håkon Wium Lie developed CSS he based a lot of the CSS concepts on TeX (see Wium Lie's phd thesis). So in order to follow what is happening with the code we will do two things; first put everything in its own box and secondly frame everything using a LaTeX \fbox. TeX provides two major types of boxes ...

47

Another approach, usable with LuaLaTeX. The following sample document was made with the files below. The TeX input file \documentclass{article} \directlua{ require("drawboxes")} \usepackage{graphicx,atbegshi} \AtBeginShipout {\directlua{drawboxes.visual_debug()}} \begin{document} \hsize 3in A wonderful serenity has taken possession of my entire soul, like ...

47

A minipage environment is a sufficient way to box or group something: \documentclass{article} \begin{document} \begin{minipage}{15em} The quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick ...

47

I made the following diagram for the adjustbox bundle. It will be part of the trimclip manual (The trimclip package will be an extracted part of the current adjustbox package). As you can see the text lies on the baseline, the height is everything above it and the depth everything below it. Usually only some lower-case character and punctuation go below it. ...

47

You can use the bclogo and/or mdframed and or tcolorbox packages. The main difference is that boxes produced using mdframed or tcolorbox might allow page breaks. A little example; the first box was produced using bclogo; the second one, using mdframed; the third one (similar to the second one) and the fourth one were produced using tcolorbox: \...

47

This is a job for the fit library. 1. Initial Guess: Using the fit= and specifying the nodes around which you want the box fit: \node [draw=red, fit= (B) (C) (D)] {}; \node [draw=red, fit= (D) (E) (F)] {}; gets you pretty close to what you want: Now it is just a matter of adjusting the boxes. 2. Add inner sep= Note that the boxes are tightly fit ...

46

I come here looking for the answer to the same question. I wanted it to look nice as well, have colour on the inside too, but unfortunately when trying to implement the suggestions above it didn't seem to work for multiple lines. What I did was go to the tcolorbox manual http://get-software.net/macros/latex/contrib/tcolorbox/tcolorbox.pdf and had a quick ...

44

This can be easily done with adjustbox v0.8 from 2011/11/14. It provides the original width as \Width which can be used to center the rotated content around it (with the rest overlapping on the left and right) or to calculate the amount which the rotated content should overlap to the left, which is the \hskip you are talking about. The current width is ...

43

2016 Christmas Edition I experimented here with trying to produce a geometric figure near the firework core, by using simple glyphs like + and -. When duplicated with rotation and shift, I think the effect is very nice way to highlight the event. 2015 CHRISTMAS EDITION Here I introduce my first triple-burst firework, with "For unto us" as the inner burst,...

40

You could use the pgf-blur package, which gives you this: In fact, it can add a "faded" drop shadow to pretty much anything: The shadow fading is not continuous, like in the previously accepted answer. It fades in a number of discrete steps, but that number can be changed, see the documentation. Here's the code for the examples: \documentclass{article} \...

40

tcolorbox also offers several options for boxed math expressions. tcbhighmath is an special box which can be used with empheq package, but it's also easy to declare new boxes to use with empheq. Some examples with the code: \documentclass{article} \usepackage{amsmath} \usepackage{empheq} \usepackage[most]{tcolorbox} \newtcbox{\mymath}[1][]{% ...

39

This is what you want: And use the height and width of ( for \structbox: You may need to read the TeXbook or similar books for Plain TeX (esp. free books TeX for the Impatient and TeX by Topic) to understand the \hbox and \vbox well.

39

A LuaTeX solution. Should work in all situations that I am aware of: \documentclass{article} \usepackage{luacode,luatexbase} \begin{document} \begin{luacode*} local GLYPH_ID = node.id("glyph") local number_sp_in_a_pdf_point = 65782 function math.round(num) return math.floor(num * 1000 + 0.5) / 1000 end -- width/height/depth of a glyph and the whatsit ...

39

The tcolorbox package does a beautiful job of setting coloured boxes: \documentclass{article} \usepackage{tcolorbox}% http://ctan.org/pkg/tcolorbox \definecolor{mycolor}{rgb}{0.122, 0.435, 0.698}% Rule colour \makeatletter \newcommand{\mybox}[1]{% \setbox0=\hbox{#1}% \setlength{\@tempdima}{\dimexpr\wd0+13pt}% \begin{tcolorbox}[colframe=mycolor,boxrule=...

37

Each are defined as follows in the default document classes (article, book and report): \strut \def\strut{\relax\ifmmode\copy\strutbox\else\unhcopy\strutbox\fi} with \strutbox defined as \setbox\strutbox\hbox{% \vrule\@height.7\baselineskip \@depth.3\baselineskip \@width\z@}% \mathstrut \def\mathstrut{\vphantom(} Using \mathstrut ...

35

The problem here is that \colorbox reverts it's argument back to text mode. And, since you're using math-related macros (like \left, \right, \frac and \ell) in text mode, TeX complains about a missing $. So you need to explicitly state that you're in math mode using: \newcommand{\highlight}[1]{\colorbox{yellow}{$\displaystyle #1\$}} I've added the \...

Only top voted, non community-wiki answers of a minimum length are eligible