The Stack Overflow podcast is back! Listen to an interview with our new CEO.
148

I know this question has been answered very extensively. But not what I wanted or thought was the question based on the title. Therefore if others get in here looking for a possibility for colouring behind a word than this snippet is much easier: \colorbox{blue!30}{blue} or \textcolor{blue!30}{blue} resulting in: This is possible by only adding \...


51

You could use the \afterpage command from the afterpage package to change the color back. Here's an example: \documentclass{article} \usepackage{lipsum}% for auto generating text \usepackage{afterpage} \usepackage{xcolor} \begin{document} \lipsum[1-12] \pagecolor{yellow}\afterpage{\nopagecolor} \lipsum[22-30] \end{document}


40

Update with minimal and maximal values Minimal values are only usable when negative values are disabled (\negativeValuesfalse). Code \documentclass{article} \usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor \usepackage{tikz,array,collcell} \usetikzlibrary{calc} \pgfdeclarelayer{background} \pgfdeclarelayer{main} \pgfsetlayers{background,main} \newif\...


36

TiKZ 3.0.0 introduces pic a "short picture" which can be inserted in any place of a tikzpicture. A possible solution with 'pic' would be: \documentclass{standalone} \usepackage[margin = 1in]{geometry} \usepackage{tikz} \usetikzlibrary{decorations.pathmorphing,calc,shapes,shapes.geometric,patterns} \begin{document} \tikzset{treetop/.style = {decoration={...


32

You can use TikZ to place the image in a \node with the desired opacity: \documentclass{beamer} \usepackage{tikz} \usebackgroundtemplate{% \tikz\node[opacity=0.3] {\includegraphics[height=\paperheight,width=\paperwidth]{ctanlion}};} \begin{document} \begin{frame} CTAN lion drawing by Duane Bibby. \end{frame} \end{document} In this case, it might be ...


32

Thanks to Andrew Stacey for pointing me to the new improved tikzmkark. I was not aware of it. This version of \tikzmark allows for using the defined coordinates before the point of its definition. Using \tikzmark{foo} a new coordinate named (pic cs:foo) is available and can be used anywhere in the page. Using the new \tikzmark, taken from the preamble of ...


30

You can use \rowcolor, \columncolor, and \cellcolor from the colortbl package, loaded in my example through the xcolor package: \documentclass{article} \usepackage{amsmath} \usepackage[table]{xcolor} \newcommand\x{\times} \newcommand\y{\cellcolor{green!10}} \begin{document} \begin{equation}\label{eq:appendrow} \left(\begin{array}{cccc} \rowcolor{...


29

You can box the image and then use \vfil and \hfil to center it: \PassOptionsToPackage{demo}{graphicx} \documentclass{beamer} \usebackgroundtemplate{% \vbox to \paperheight{\vfil\hbox to \paperwidth{\hfil\includegraphics[width=1.5in]{name}\hfil}\vfil} } \begin{document} \begin{frame} Test \end{frame} \end{document} The line \PassOptionsToPackage{demo}...


28

Another sans-TikZ alterantive: \documentclass{article} \usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor \usepackage[nomessages]{fp}% http://ctan.org/pkg/fp \newcommand{\maxnum}{100.00} \newlength{\maxlen} \newcommand{\databar}[2][green!25]{% \settowidth{\maxlen}{\maxnum}% \addtolength{\maxlen}{\tabcolsep}% \FPeval\result{round(#2/\maxnum:4)}% \...


27

To circumvent the issue of \nopagecolor being only available for pdfTeX and LuaTeX, you could use the pagecolor package and \newpagecolor{yellow} to set the new page color and \restorepagecolor to restore the pagecolor to the one it was before \newpagecolor{yellow} was used. If that color was white, it is white again, if it was none, it is none again, and if ...


27

The solution below defines two alternative ways of drawing a coloured gradient in the margin background on a selection of pages: Invoke the \conditionalmarginbg (which takes no argument) at the beginning of your document and then toggle the margin background on/off in your document by using the \startdrawmarginbg and \stopdrawmarginbg macros. Invoke \...


26

So if I understood your question correctly, you want to do something like GitHub's markdown style. So I created some commands and environments to supply a GitHub-like style based on Adam Pritchard's Markdown Cheatsheet. I used Source Sans Pro and Source Code Pro fonts, so you'll have to download and install them on your operating system. Here are the direct ...


26

This solution, using nested stack insets, still has vertical height/depth to the overlay. The relative placement of the insets is controlled by the length parameters (2nd and 4th arguments of \stackinset are (x,y) offsets). \documentclass{article} \usepackage{stackengine} \usepackage{xcolor} \begin{document} \def\MyText{not scary} \newcommand\mytext[1][...


23

This is for a section, but you can extend it easily for subsections with a similar scheme: \documentclass[a4paper]{scrbook} \usepackage{xcolor,lipsum} \usepackage{titlesec} \titleformat{name=\section}[block] {\sffamily\large} {} {0pt} {\colorsection} \titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip} \newcommand{\colorsection}[1]{% \...


22

You could check for the frame number: \setbeamertemplate{background canvas}{% \ifnum\c@framenumber=1% % On title page \fi% } You may extend this to set thing to all frames except the title: \setbeamertemplate{background canvas}{% \ifnum\c@framenumber=1% % On title page \else% % Other frames background \fi% } ...


22

Include the white frames into a group with an empty usebackgroundtemplate \documentclass{beamer} \usebackgroundtemplate% { \centering\includegraphics[width=\paperwidth,height=\paperheight{bgs/global.png} } \begin{document} \begin{frame} this frame will have the global background \end{frame} { \usebackgroundtemplate{} \begin{frame} This frame ...


21

The idea is simple: use some nontrivial blending mode. You might want to tune the colors, so that "blue" minus "yellow" is "white" modify the background, so that the lower right corner looks right. I test the document with Preview and Adobe Reader on Mac. \documentclass{beamer} \usepackage{tikz} \usetheme{Madrid} \usebackgroundtemplate{ \begin{...


21

You can use path picture and path picture bounding box: \documentclass[tikz,margin=5mm]{standalone} \usetikzlibrary{calc} \begin{document} \tikz \node[draw] [path picture={ \fill[gray!30](path picture bounding box.north west)rectangle ($(path picture bounding box.north east)!.75!(path picture bounding box.south east)$); }](n) {Some Text} ; ...


20

You could specify the opacity of your blocks using \addtobeamertemplate: \addtobeamertemplate{block begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}} \addtobeamertemplate{block alerted begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}} \addtobeamertemplate{block example begin}{\pgfsetfillopacity{0.5}}{\pgfsetfillopacity{1}} It doesn't work well ...


18

The credits should go to Martin Scharrer. It is possible with the listings package: \documentclass{article} \usepackage{listings,color} \definecolor{verbgray}{gray}{0.9} \lstnewenvironment{code}{% \lstset{backgroundcolor=\color{verbgray}, frame=single, framerule=0pt, basicstyle=\ttfamily, columns=fullflexible}}{} \definecolor{shadecolor}{rgb}{....


18

I would define a specific key for the tree and one for the position: % to get the positions of last x,y \newdimen\xval \newdimen\yval \pgfkeys{/tikz/.cd, at/.initial={(0,0)}, at/.get=\coordpos, at/.store in=\coordpos, my tree/.code={ \foreach \w/\f in {0.3/30,0.2/50,0.1/70} { \fill [brown!\f!black, trunk] \coordpos ++(-\w/2,0) ...


18

With WriteLaTeX's frog.jpg, also in https://www.writelatex.com/542861kyqykv \documentclass{beamer} \usetheme{Warsaw} \usepackage{tikz} \usetikzlibrary{fadings} \setbeamertemplate{background}{% \begin{tikzpicture} \path (0,0) rectangle (\paperwidth,\paperheight); \node[scope fading=west,inner sep=0pt,outer sep=0pt,anchor=north east] at(\paperwidth,\...


18

The key backgroundcolor of the lstlisting is what you are looking for for the colored background. To indent a bit the code, play with xleftmargin and framexleftmargin to fit your needs. \documentclass{article} \usepackage{xcolor} \usepackage{listings} \begin{document} Test \begin{lstlisting}[backgroundcolor = \color{lightgray}, language =...


18

Solution without TikZ Using text as clip path is supported by package pdfrender if pdfTeX (or LuaTeX) is running in PDF mode. \pdfsave and \pdfrestore saves and restores the current graphics state, thus that the clipping ends after \pdfrestore. Since the graphics state include the current transfer matrix (e.g., the current point on the PDF page), the ...


17

Improved version (Other versions can be consulted in the edit history of the answer) Using the xkeyvalue package, this new version has a \EducNotebook command with a key-value system to control the attributes; the main features are: The spiral can be drawn on top, to the left or to the right. The user can select the number of spirals to be used. The user ...


17

This is a slightly tweaked solution based on Mark Wibrow's answer. It adds the fit library so that the front node (the one with the text) stretches to cover the background image without having to set the size manually. This is the image source (place it in your Tex folder where the main document is, and rename it vegetation). Output Code \documentclass[...


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