How to create a sidebar with latex? - latex

I need to make a journal, and I want to have a "recommended books" on the side of the page within the last page of the journal, but I couldn't find anything that would give me this result. I'm already using multicols package for the content and i cant see how a graphicx package would help me out.
I want to have a nice blue background with rounded corners too, help is welcome ^^.

If you are already using multicol, just make it another column and draw a box around it with the usual techniques. Maybe not the fanciest solution, but it seems like it should work. Use \newcolumn in the multicol environment to put the sidebar in its own column. For your fancy boxes, try the fancybox package. With it, you can draw boxes with rounded corners.
On the other hand, this guy gets super fancy and uses the TikZ package to get colors and all sorts of stuff.

Related

How to configure tcolorbox in lyx?

I’ve been trying for the days now to format attractive code listings in lyx for an Erlang programming book that I’m working on.
The tcolorbox package looks like it should do the trick, but frustrates me at every turn,
Requirements:
Shaded Box with rounded corners, white header text on black, black outline, black on white body text
Head centered and of the form “Listing CN.LN comment” where CN is chapter number and LN is listing number and comment is in italics.
I can do this with a LaTeX macro, but can’t make it work in the head of a shaded box.
Code listing in the body must be mono space font with bold face highlighting.
I’ve read the tcolorbox manual, but still don’t understand how it works in lyx.
Can some kind souls please help dispel my ignorance?
LRP
I'm not sure about all the details of your requirements (could you post the LaTeX that works?) Try the following to get you started (I'm using LyX 2.2.x):
Document > Settings > Modules > Fancy Colored Boxes > Add > Apply
Insert > Custom Insets > Color Box
Inside the Color Box inset, you can find Color Box Options (right-click, or ALT-A 1 in Windows). Those options look similar to the syntax of tcolorbox, e.g.:
title=An enhanced box with a color gradient, enhanced, frame style={left color=red!75!black, right color=blue!75!black}, interior style={left color=red!20!white, right color=yellow!50!white}
Finally, there's an Example (in the LyX Resources/Examples folder) called colored-boxes.lyx that has a lot of info.

Latex color box inline with text

I'm trying to put together a LaTeX color box. The xcolor package \fcolorbox seem to be what I want, but I can't get the rendering quite correct. When I use
\fcolorbox{black}{red}{}
it renders a small box sunken to the bottom of the text line. The best I've managed to do is to fake it with a similar text color:
\fcolorbox{black}{red}{\textcolor{red}{--}}
However, I'm worried that this won't render correctly in all situations with defined colors. Is there a way I can declare an empty text box with full in-line text height? Is there another solution?
I'm basically looking for the code that produces the color boxes all through the document at ftp://ftp.dante.de/pub/tex/macros/latex/contrib/xcolor/xcolor.pdf. The boxes I'm referring to are used throughout, but the first instance is on page 4. Thanks.
The xcolor.dtx file in the same directory as the pdf contains the source for the package and the source for the documentation. The relevant bits from the source for the documentation:
\def\testclr#1#{\#testclr{#1}}
\def\#testclr#1#2{{\fboxsep\z#\fbox{\colorbox#1{#2}{\phantom{XX}}}}}
...
(Answer: 40\% \testclr{green} $+$ 60\% \testclr{yellow} $=$ \testclr{green!40!yellow}, e.g., |\color{green!40!yellow}|)
Basically, use \phantom{} on the contents of your color box, and make sure that at least one of the phantom characters is full-height.
Also, https://tex.stackexchange.com/

How to add changebar in latex?

In Latex, I've created a new command 'changedtext' to mark specifics parts in my document and make it appear blue:
\newcommand{\changedtext}[1]{\textcolor{blue}{#1} }
Is there any easy way to alter the command to have change bars appear next to the text in the resulting PDF?
If not possible, any other suggestion for a visual markup (other than change bars) that would be clear on a black & white printout would be useful as well.
Update: It might be of interest to readers of this question that some time ago I started using the latexdiff script to mark up changes between two versions. I use it in combination with SVN, which I think works great; if you split up your LaTeX files, you might want to look at this tex.stackexchange question though.
Use one of the changebar macro packages in your command.
One other way which would be very clear in B&W would be highlight (shows as gray background).
Use packages soul and color and define your highlight color:
\usepackage{soul}
\usepackage{color}
\definecolor{lightgray}{rgb}{.92,.92,.92}
\sethlcolor{lightgray}
Now you can use \hl{highlighted text} in text to highlight.
Some half-baked solution (not satisfactory) I just came up with myself, is the use of \marginpar to have some arbitrary indication in the margin, e.g.:
\newcommand{\changedtext}[1]{\textcolor{blue}{#1 \marginpar{r1}} }
will put the text 'r1' (from revision 1) in the margin.
However, when using this, the \changedtext command can not be used everywhere (e.g. in formulas, captions) because LateX will complain (in my case) about 'float(s) lost'.
Still,it might be useful to some people...

Can sIFR show fonts on a blue line (like writing on notebook paper)?

I encountered a use case where the business would like to display an answer to a question in a handwritten font. So, my initial thought was to use sIFR, but the other part of the use case is they want the handwritten font on blue lines, analogous to writing in a paper notepad or notebook. Can sIFR do a stylized font + notebook lines, or do I need to use another technique? Thank you in advance.
Yes. You can follow the tutorial here to get your blue lines in place: Use custom type with sIFR
However, I would caution against the use of sIFR for whole paragraphs of text. Mike Davidson mentions this in his best practices here.
Raithlin,
Thanks for the link to the article. I read Mike Davidson's page, and I am aware of the problems with replacing too much text. It is something I will warn the business users about.

Is there a way to get LaTeX to place figures in the same page as a reference to that figure?

I am using LaTeX and the figure environment.
I am well familiar with the parameters to that environment: [htbp], and I am also generally familiar with the strategies that LaTeX takes, by default, to decide where to put each figure. For example, by placing figures at the top or bottom of the page.
What I am wondering is whether there is a package, macro, or some commands that I can give so that if I have a single-column document and I mostly have a single in-text reference to a figure, that the figure would be more likely to be placed in the same page of the reference?
For example, imagine that I have a long paragraph which in the middle has a \ref{FIG:X}. When rendered, some of the paragraph appears before the page break, and some appears after the page break. I can also place the figure command somewhere before and after the whole paragraph. Is there a way to get it to actually be placed in the same page as the actual reference?
I don't want to sound too negative, but there are occasions when what you want is almost impossible without a lot of "artificial" tuning of page breaks.
If the callout falls naturally near the bottom of a page, and the figure falls on the following page, moving the figure back one page will probably displace the callout forward.
I would recommend (as far as possible, and depending on the exact size of the figures):
Place the figures with [t] (or [h] if you must)
Place the figures as near as possible to the "right" place (differs for [t] and [h])
Include the figures from separate files with \input, which will make them much easier to move around when you're doing the final tuning
In my experience, this is a big eater-up of non-available time (:-)
In reply to Jon's comment, I think this is an inherently difficult problem, because the LaTeX guys are no slouches. You may like to read Frank Mittelbach's paper.
Yes, include float package into the top of your document and H (capital H) as a figure specifier:
\usepackage{float}
\begin{figure}[H]
.
.
.
\end{figure}
You can always add the "!" into your float-options. This way, latex tries really hard to place the figure where you want it (I mostly use [h!tb]), stretching the normal rules of type-setting.
I have found another solution:
Use the float-package. This way you can place the figures where you want them to be.
I solve this problem by always using the [h] option on floats (such as figures) so that they (mostly) go where I place them. Then when I look at the final draft, I adjust the location of the float by moving it in the LaTeX source. Usually that means moving it around the paragraph where it is referenced. Sometimes I need to add a page break at an appropriate spot.
I've found that the default placement of floats is reasonable in LaTeX, but manual adjustments are almost always needed to get things like this just right. (And sometimes it isn't possible for everything to be perfect when there are lots of floats and footnotes.)
The manual for the memoir class has some good information about how LaTeX places floats and some advice for manipulating the algorithm.
If you want force this behaviour on all of your figures try
...
\usepackage{float}
\floatplacement{figure}{H}
...
Maybe this will help you?
\begin{center}
\includegraphics[scale=0.5]{picture_name}
\end{center}
I think is better to use the graphics command when your figures run away.
I have some useful comments. Because I had similar problem with location of figures.
I used package "wrapfig" that allows to make figures wrapped by text.
Something like
...
\usepackage{wrapfig}
\usepackage{graphicx}
...
\begin{wrapfigure}{r}{53pt}
\includegraphics[width=53pt]{cone.pdf}
\end{wrapfigure}
In options {r} means to put figure from right side. {l} can be use for left side.
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.85}
\renewcommand{\textfraction}{0.15}
\renewcommand{\floatpagefraction}{0.7}
http://robjhyndman.com/researchtips/latex-floats/
One way I found that helps with this is to use \include{file_with_tex_figure_commands}
(not input)

Resources