Hot answers tagged

81

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

Here's one approach that uses the titlesec package for setting the section titles, and TikZ for drawing the bar. The section numbers are placed in a TikZ node that will grow automatically to accommodate the numbers: \documentclass{book} \usepackage{titlesec} \usepackage{lipsum} \usepackage{tikz}\usetikzlibrary{shapes.misc} \newcommand\titlebar{% \tikz[...


52

You could take a look at mdframed, which also allows pagebreaks, and allows you to customize the look of the frame. A simple example, which puts a box similar to \fbox around the content. \documentclass{article} \usepackage{mdframed} \usepackage{lipsum} % for creating dummy text \begin{document} \begin{mdframed} \lipsum[1] \begin{equation} f(x) = \sin(x) \...


46

You could use TikZ, and the fit library for creating nodes fitting the desired area, a style for the highlighted node, so separated from the code and easy to change, the TikZ options overlay and remember picture, so you can later refer to those nodes, for example for drawing arrows and annotations later. To demonstrate why it's useful to have nodes for ...


44

I recommend TikZ. The result: The code: \documentclass{article} \usepackage{amsmath} \usepackage{tikz} \usetikzlibrary{arrows,matrix,positioning} \begin{document} \begin{tikzpicture} \matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m) { 8 &8 &1 &6 \\ 3 &8 &5 &...


42

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][]{% ...


38

\begin{minipage}[t][10cm][t]{\textwidth} will make a top aligned minipage that is 10cm tall.


35

You can use \tikzmark from this answer by Andrew Stacey to mark the endpoints where you want the box. This allows you to do the matrix in the usual way (outside of tikz). Since this is very similar to Werner's solution that used pstricks, I adapted that code to use \tikzmark: Notes: This does require two runs: the first to compute the positions of the ...


31

Here is a solution using TikZ. You may also want to read the solution suggested by percusse in his comment, although I think my solution is simpler to understand for a newcommer to TikZ. comment: My original solution included an align command in the matrix, this actually turned everything in the matrix into text, not math stuff. I removed the align ...


28

You should add a \strut so that all boxes have the same maximal height and depth, otherwise the framed box will depend on the height of the content. This means that an a gets a small box and Xy gets a higher and deeper one. With \strut a invisible rule is added which has the maximum height and depth of the current font size. \newcommand*{\tag}[1]{\fbox{#1\...


28

One way to do that is to adapt the code from Highlight elements in the matrix. Below, I provide two macros \DrawBox and \DrawBoxWide depending on if you want to include the list markers or not. The default below is to produce a red box, but this can be adjusted to suit, or the options can be specified on a per use basis (as in the second example): However,...


28

As mentioned by Torbjørn T. minted has some options to add a frame. However minted doesn't do the frame. This is done by the package fancyvrb. The possibilities of frames with fancyvrb are limited. If you want e.g. round corners you can use another package like tcolorbox or mdframed. The example below shows you the usage of tcolorbox. I am using the ...


27

From its announcement in CTAN list (December, 2011) tcolorbox provides an environment for colored and framed text boxes with a heading line. Optionally, such a box can be splitted in an upper and a lower part. The package tcolorbox can be used for the setting of LaTeX examples where one part of the box displays the source code and the other ...


27

\framebox puts a frame around the box that you give it, and in TeX, boxes fit tightly around their object. So two \framebox around two different text boxes, say "This" and "example" will have different sizes, as can be seen in the MWE and resulting output below: \documentclass{article} \newcommand*{\mybox}[1]{\framebox{#1}} \begin{document} \mybox{This} \...


27

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)^{-...


26

Here's a method that doesn't require loading TikZ explicitly. (Although mdframed uses tikz behind the scenes. This is, however, the package for framing boxes. \documentclass{article} \usepackage[framemethod=TikZ]{mdframed} \usepackage{lipsum} \begin{document} \begin{mdframed}[roundcorner=10pt] \lipsum[1] \end{mdframed} \end{document} If you don't even ...


26

You can use \newmdtheoremenv from the mdframed package: \documentclass{article} \usepackage{mdframed} \usepackage{lipsum} \newmdtheoremenv{theo}{Theorem} \begin{document} \begin{theo} \lipsum*[1] \end{theo} \end{document} If you only want to frame some theorems, then you can define a new environment using the mdframed environment and some previously ...


26

Here's a method that uses only LaTeX's "built-in" commands \cline and \multicolumn to create the frame around the upper-left 3x3 submatrix. By the way, because your matrix has more than 10 columns, I believe it's necessary to either use the array environment instead of the bmatrix environment (bmatrix is essentially a "wrapper" around the array construct) ...


26

Another approach always using TikZ. Since the backgrounds library was not exploited so far, I made use of it; first I defined two commands that allow to fill the background of the elements highlighted or not: \NewDocumentCommand{\highlight}{O{blue!40} m m}{% \draw[mycolor=#1] (#2.north west)rectangle (#3.south east); } \NewDocumentCommand{\fhighlight}{O{...


26

The mdframed package has what you want. Here is a MWE that demonstrates the borders you described in three new environments. There are many other options available- see the documentation for more details and examples. \documentclass{article} \usepackage{mdframed} \usepackage{lipsum} % all 4 borders \newmdenv{allfour} % just top and bottom \newmdenv[...


25

Update Now that the powerful tcolorbox and mdframed packages are around, this is an easy task: \documentclass{article} \usepackage{mdframed} \usepackage[many]{tcolorbox} \usepackage{lipsum} \newtcolorbox{tcboppbox}[1][]{ breakable, enhanced, arc=0pt, boxrule=0pt, outer arc=0pt, overlay first={ \draw[#1] ([yshift=10pt]frame.north east) -- ++...


25

This could be because your images include the border already, before including them. If this is the case, you can trim and clip some of the edges of the included image using the trim=<lx> <ly> <ux> <uy>,clip option of \includegraphics. This trims <lx> from the left, <ly> from the bottom, <ux> from the right and <...


25

One possible solution, at least for requests 1, 2 3, and 5, using mdframed: \documentclass{article} \usepackage[a5paper]{geometry} \usepackage{xcolor} \usepackage{caption} \usepackage{booktabs} \usepackage[framemethod=tikz]{mdframed} \usetikzlibrary{calc} \usepackage{lipsum} \newcounter{exa}[section] \renewcommand\theexa{\thesection.\arabic{exa}} \...


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,...


23

Perhaps something like this? \documentclass{article} \usepackage{graphicx} \usepackage{tikz} \usetikzlibrary{calc} \definecolor{tab}{RGB}{223,223,223} \definecolor{ugray}{RGB}{230,230,230} \definecolor{bgray}{RGB}{151,151,151} \definecolor{redball}{RGB}{238,93,86} \definecolor{yellowball}{RGB}{254,184,75} \definecolor{greenball}{RGB}{152,204,122} \begin{...


22

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,...


22

The xcolor package provides \fcolorbox{<frame color>}{<background color>}{<text>}. You can also use my adjustbox package with the cfbox=<color> and minipage=<width> keys: \usepackage{xcolor} \usepackage{adjustbox} % ... \adjustbox{minipage=0.25\textwidth,cfbox=<color>}{<content>} % or, if the whole thing should ...


22

General Your question is related to the packages framed and mdframed. But there are other useful packages for drawing frames around given material: tcolorbox (allows page breaks) boites (allows page breaks) ... A small list can be found via the search mechanism of CTAN Differences Before I list the differences let me start with the similarities. both ...


21

Here is a pstricks-related approach that requires pst-node: \documentclass{article} \usepackage{xcolor}% http://ctan.org/pkg/xcolor \usepackage{pst-node}% http://ctan.org/pkg/pst-node \begin{document} \[ M = \left[\begin{array}{*{13}{c}} \pnode(-.5ex,2ex){left}0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 &...


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