Hot answers tagged

114

You can also use tcolorbox: Code: \documentclass{article} \usepackage{amsmath} \usepackage{tcolorbox} \begin{document} \begin{tcolorbox} blablabla \begin{align} E &= mc^2 & \text{Formula of the universe} \end{align} Hoaray \end{tcolorbox} \end{document}


53

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

Just replace center environment with equation. I think it looks a little better with larger parentheses. Edit: It might be easier to read as a fraction - except that it seems to be an equation about matrices ... \documentclass{report} \usepackage{amsmath} \begin{document} \begin{equation} \boxed{K_{k+1}=P_ka_{k+1}^T\left(a_{k+1}P_ka_{k+1}^T+I_N\right)^{-...


31

I don't know if the tcolorbox package was available at the time that the question was asked, but here's a small example taken directly from the documentation: % arara: pdflatex \documentclass{article} \usepackage{tcolorbox} \tcbuselibrary{theorems} \newtcbtheorem[number within=section]{mytheo}{My Theorem}% {colback=green!5,colframe=green!35!black,...


24

Here's one possibility using tcolorbox: \documentclass{article} \usepackage[svgnames]{xcolor} \usepackage{tikz} \usetikzlibrary{shadows,calc} \usepackage{tcolorbox} \tcbuselibrary{skins,theorems,breakable} \usepackage{lipsum} \definecolor{myblue}{RGB}{40,96,139} \tcbset{ mybox/.style={ breakable, enhanced standard, boxrule=0.4pt,titlerule=-0.2pt,...


22

An alternative package to mdframed is tcolorbox. Among some other interesting features, includes breakable framed boxes. Using default style a simple example could be: \documentclass{article} \usepackage[most]{tcolorbox} \usepackage{lipsum} \begin{document} \vspace*{15cm} \begin{tcolorbox}[breakable, enhanced] \lipsum[1] \end{tcolorbox} \end{document} ...


21

A tcbox (or a tcolorbox) were missing in this list. Some simple examples: \documentclass[a4paper]{article} \usepackage[most]{tcolorbox} \begin{document} \tcbox{\includegraphics[width=5cm]{frog}} \tcbox[colframe=green!30!black, colback=green!30]{\includegraphics[width=5cm]{frog}} \tcbox[sharp corners, boxsep=5mm, boxrule=1mm, ...


21

Here's one possibility using the mdframed package and \marginnote from the marginnote package: \documentclass{article} \usepackage[lmargin=5cm,textwidth=15cm,marginparwidth=4cm]{geometry} \usepackage[dvipsnames]{xcolor} \usepackage{ragged2e} \usepackage[framemethod=tikz]{mdframed} \usepackage{marginnote} \usetikzlibrary{calc} \usepackage{lipsum} \...


20

Using the mdframed package defining the background colour is pretty easy: \documentclass{article} \usepackage{xcolor} \usepackage{mdframed} \begin{document} test \begin{mdframed}[backgroundcolor=blue!20] In any right triangle, the area of the square whose side is the hypotenuse is equal to the sum of the areas of the squares whose sides ...


19

Although when seamus wrote his answer, tcolorbox was not in CTAN, it was announced just one month later. And as nobody has written an answer mentioning it, I do it. So here you have a little code which shows how to declare a framed box with tcolorbox. How to change it's width, frame color, background color, text alignment, space between text and frame ...


19

At the risk of beating a dead horse, I find the framed package works most convenient. \usepackage{framed} \begin{framed} My long text that needs new lines. \end{framed} You need not worry about sizing--line breaks are automatic. It works well with the beamer class too.


19

Update. Improved version: \tikzmark is used to set marks at the beginning and end of the text that will be boxed. The main command is \BoxedText[<options>]{<start-mark>}{<end-mark>} The optional argument can be used to pass options to the \draw command used internally (by default, just a frame is drawn, but you can fill it, or change the ...


19

The package documentation is your friend. \documentclass{article} \usepackage{xcolor} \usepackage{framed} \definecolor{shadecolor}{rgb}{1,0,0} \begin{document} \begin{shaded*} Let me have a background :( \end{shaded*} \end{document}


18

You can enclose your text with \parbox first then \fbox, such that: \fbox{\parbox{\textwidth}{The \textit{two-step} model of XMCD: \begin{itemize} \item In the \textit{first step}, circularly polarized X-rays generate photoelectrons with a spin and/or orbital momentum from a localized atomic inner shell. \item In the \textit{second step}, the 3d shell serves ...


18

Francis already gave an answer with \parbox. Werner gave a comment for boundaries. I would recommend to use the framed-environment: \documentclass{scrartcl} \usepackage{framed} \begin{document} \section{With parbox} \fbox{\parbox{\textwidth}{The \textit{two-step} model of XMCD: \begin{itemize} \item In the \textit{first step}, circularly polarized X-...


18

Try the mdframed package. \documentclass{article} \usepackage{mdframed} \begin{document} \begin{mdframed} \section{This is a framed section} This is the text. \end{mdframed} \end{document}


18

There is always the tikz solution. Here is one that use bascially the same code from Highlight elements in the matrix but with a more flexible \DrawBox macro. And since it is tikz you get all the additional flexibility that comes with that: Usage: You use \tikzmark{<name>} to "mark" a particular location with <name>. These named ...


17

Although it's an old question, none of the answers mention tcolorbox package which provides an environment for colored and framed text boxes with a heading line. It declares an environment tcolorbox uses to build colored boxes which by default occupy the line width. These boxes can be completely customized, allow page breaks and can contain any kind of text ...


17

Set the contents of the \framebox in a \parbox: \documentclass{article} \begin{document} \noindent \framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{\itshape% If this script fails, you can try the following: lower the degree~(d), decrease the number of simplices, increase the order of continuity (if possible) or increase the number of ...


17

Update: The notes have been requested to be inside the story box. Now I offer two options, both of them with automatic numbering for the notes and with the possibility to cross-reference them: In this first option, the box for the story has a width equal to \textwidth, but the story text goes to the left of the box; the notes appear to the left of the text:...


17

With tcolorbox help it's possible to include equation numbers in framed environments. It provides options ams equation, ams gather, ams align and corresponding starred versions. It's also possible to combine tcolorbox with empheq package. \documentclass{report} \usepackage{amsmath} \usepackage[most]{tcolorbox} \tcbset{colback=yellow!10!white, colframe=red!...


16

I don't know which fonts do you use and I made the example for pdflatex so, you'll have to adapt to xetex. But the box is quite similar to the one you want. It's made with tcolorbox. \documentclass{beamer} \usetheme{Madrid} \usepackage{tcolorbox} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[french]{babel} \usepackage{lmodern} \...


13

\boxed in amsmath is defined using a regular \fbox: \newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}} So, setting \fboxsep would modify the gap. Here is an example: \documentclass{article} \usepackage{amsmath}% http://ctan.org/pkg/amsmath \begin{document} \[ \boxed{\leq} \quad \setlength{\fboxsep}{.5\fboxsep}\boxed{\leq} \quad \setlength{\...


13

If you want a costumized box, you can use the empheq package: \documentclass{article} \usepackage{mathtools} \usepackage[ amsmath ]{empheq} \usepackage{xcolor} \definecolor{shadecolor}{cmyk}{0,0,0.45,0} \definecolor{light-blue}{cmyk}{0.25,0,0,0} \newsavebox{\mysaveboxM} \newsavebox{\mysaveboxT} \newcommand*\Garybox[2][A Nice Box]{% \sbox{\mysaveboxM}{#...


13

Do you mean something like this? Code: \documentclass{article} \usepackage{tikz} \usetikzlibrary{calc} \usepackage{eso-pic} \usepackage{lipsum} \AddToShipoutPictureBG{% \begin{tikzpicture}[overlay,remember picture] \draw[line width=4pt] ($ (current page.north west) + (1cm,-1cm) $) rectangle ($ (current page.south east) + (-1cm,1cm) $); \draw[...


13

You can use the textbackground environment to put a frame around the content of a section. With the beforesection and aftersection keys you can start and stop the frame at the begin and end of a section but you have to use start/stop-version of a section command to get this working. Unlike other mechanism like the background environment textbackground doesn’...


12

The listings package can interact nicely with the multicol package. The frame stuff is done with the help of tcolorbox which, in turn, plays nicely with listings. It seems to be transitive! The idea to highlight the numbers is taken from Gonzalo's answer. \documentclass[landscape]{article} \usepackage[margin = 2cm, includeheadfoot]{geometry} \usepackage{...


12

Change font, text and colors according your needs. This code was adapted from my answer to SWOT Matrix using TikZ \documentclass[10pt,tikz,border=2mm]{standalone} \usepackage{times} \usepackage{tikz} \usetikzlibrary{matrix} \colorlet{helpful}{lime!70} \colorlet{harmful}{red!30} \colorlet{internal}{yellow!20} \colorlet{external}{cyan!30} \colorlet{S}{...


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