Graying out texts with/without lines with LaTeX? - latex

This is a screen capture from Pragmatic Bookshelf.
How to make this boxed text with LaTeX? It has it's own heading with underline, and uses color.
And how to make some text with gray background as follows?
http://img20.imageshack.us/img20/7351/screenshot20100718at916.png
Added
Konrad's method works, but it looks like that it doesn't work well with multicolumn package.
Tonio's method shows the gray only for the characters, but I want to have the gray box expanded to the end of \textwidth.
http://img714.imageshack.us/img714/8417/screenshot20100718at247.png
I posted another question with respect to the \texwidth, and it seems to working anyway.

The rounded box is most easily created using TikZ:
\begin{tikzpicture}
\draw node[draw=black,fill=black!20,rounded corners,inner sep=2ex,text width=\textwidth] {
Lorem ipsum dolor sit amet \dots
};
\end{tikzpicture}

You should use the color package.
For example,
\colorbox{red}{Black text on red background}
creates a black text, with a red background.
A good description of the color capabilities can be seen here, and an extended example here.

Related

Overlaying off-margin figure over another on Latex using Tikz

I was hoping anyone could help me with this. I am working with Latex and the Tikz package (I'm a new user on both) on a document cover using 2 figures so it looks like this:
That is, the background image leaves a thin margin on all sides, and the logo falls off-margin to the right and bottom. So, I enter the code overlaying the the logo over the background using Tikz, and as soon as I edit the coordinates to get the logo to go off-margin either on the right or bottom, the background image starts moving to the left and top until it sticks to the opposing borders of the page, like this:
My question is, is there a way to have the superimposing image to fall off the margins while keeping the background image properly centered?
Here is the code I'm using:
\usepackage{mwe,tikz}
\begin{figure}
\begin{tikzpicture}[
every node/.style={anchor=south west,inner sep=20pt},
x=1mm, y=1mm,
]
\node (fig1) at (0,0)
{\includegraphics[scale=0.2]{Images/Background.jpg}};
\node (fig2) at (124,-23)
{\includegraphics[scale=1.5]{Images/Logo.png}};
\end{tikzpicture}
\end{figure}
I first tried using the Overpic package instead, but I found it to be rather limited (or I couldn't figure it out well enough probably). I then tried using \centering and other horizontal and vertical centering techniques in combination with Tikz, but to no avail.
A figure environment is a floating objects, which allows latex to find a good location within the text flow. If you want an image at a very specific position, like a title page, you shouldn't use a figure environment
using the overlay option will make sure that the actual size of the tikzpicture does not influence the positioning and thus a cutoff logo won't influence the rest of the page
I also suggest the remember picture option which allows you to position your nodes with respect to the page. This way you can place the big picture in the centre of the page and the smaller picture at the lower right corner (shift it around with the xshift and yshift keys)
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node at (current page.center) {\includegraphics[width=.9\paperwidth,height=.9\paperheight]{example-image-10x16}};
\node at ([xshift=-2cm,yshift=1cm]current page.south east) {\includegraphics[width=15cm]{example-image-duck}};
\end{tikzpicture}
\end{document}

Add logo in very bottom right corner

I have been trying to insert a (transparent) logo in the bottom right corner in the background of my title page without affecting the text in Overleaf. Unfortunately, I haven't found a similar use case and have tried many different options for quite some time, but it doesn't work the way I need it to. Can someone please help me in this regard?
I would like it to look like this. As you can see, there is a logo inserted in the lower right corner.
You can add an image to the page background via the shipout/background hook. To make positioning easier, I'm using tikz in the following example:
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\AddToHookNext{shipout/background}{
\begin{tikzpicture}[remember picture, overlay,inner sep=0pt,outer sep=0pt,opacity=0.5]
\node[anchor=south east] at ([xshift=3cm,yshift=-3cm]current page.south east) {
\includegraphics[width=16cm]{example-image-duck}
};
\end{tikzpicture}
}
\begin{document}
\lipsum
\end{document}

Latex: Insert vertical space after includegraphics

I'm using the scrartcl documentclass and try to insert some vertical space after including an image.
Lorem ipsum...\\\\
\includegraphics[width=\textwidth]{image.png}
% Add vertical space here
Lorem ipsum...
Before the image I can just add like \\\\ to add some space (which I don't like as well...), but I can't add these after the image because there is no line to end.
Is there an option to add a margin before and after the image?
I know that I could use figures, but I like the simple way of just adding one simple line of \inludegraphics{blah}
You should try using \vspace. \\ just adds newlines while \vspace adds vertical skips. Alternatively you could use \smallskip \medskip or \bigskip.

LateX: Equation Like "box" for a block of text

Hi I'm using LateX. I have a block of text that I'd like to have a small box like space highlighting the are (just like a \begin{equation} but for text).
Is there such a thing in LateX?
I'm not 100% sure what you're asking I'm afraid, but if you just want to indent text with a margin on each side of the page to make it stand out, you can use...
\begin{quotation}
Quotation is good for long blocks of text that you want highlighted
\end{quotation}
\begin{quote}
Quote is suited to a single block of quoted text.
\end{quote}
If you actually want to have a physical black box around the text, you might want to consider wrapping it in a tabular / table, or you might want to delve into minipages and/or par box environments...
Is \makebox what you're looking for?
To create boxes of text that behave differently from the rest of the text, we can use
\makebox[width][pos]{text}
The width sets the width the of the box. The pos sets the positioning of the text - either r (right justified text), l (left justified), or s (stretched to fill the box). If the pos parameter is left out, as in \makebox[1in]{centerme}, the text is centered. The text is placed in the box. If you want to draw a box around the text, use \framebox just as you would use \makebox.
\mbox{text} and \fbox{text} are quick versions of \makebox and \framebox, which create a box to fit the size of the text.
There are some more examples at http://www.artofproblemsolving.com/wiki/index.php?title=LaTeX:Layout#Boxes

Making LaTeX Beamer Black & White

Is there a way to make LaTeX Beamer output black & white? I need it for paper printing purposes. I'm using the default color theme, and for contrast reasons I need the title and everything to be black. If there is a black&white color scheme, I could use it, but otherwise I don't want other color schemes, with colored backgrounds. Maybe there are some commands which I can redefine?
Thanks.
You can also just add gray option to documentclass declaration:
\documentclass[gray]{beamer}
...
OK, found it after some more search. The answer is:
\setbeamercolor{frametitle}{fg=black}
In fact, you can change the color of all elements of your beamer theme using \setbeamercolor. You can use fg for changing the foreground and bg for the background. The problem of this is that you cannot use the traditional rbg scheme and you have to make very strange combinations of colors with a not-very-friendly way of giving the shares of each color you want to combine
Another possibility is to use \selectcolormodel{gray}
\documentclass{beamer}
\usetheme{CambridgeUS}
\selectcolormodel{gray}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}

Resources