Blog

Text | Decorative quotation marks

In the  pifont package you can define and find these quotation marks:

Pifont_Quotationmarks

For a whole list of  pifont ‘s symbols, see this post.

Source: tug.ctan.org [pdf, page 16]

Advertisements

Table, Text | Reduce white space after table

When having a table with the caption above the table, it seems that there is too many white space created after the table. I wanted to reduce/remove the white spaces manually, only for some tables. I could not find the solution after searching on Google while the solution is so simple! I wasted my time on the search engine. 😦

Solution: put a negative \vspace{} before you end the table!

This is very important, because when placing the negative “\vspace{}” after “\end{table}” and you have a float with [h], it will only reduce the white space of the text, so this could be somewhere else in your document. Place it before the table ends!

Example:

\begin{table}[h] 
\captionsetup{width=0.8\linewidth} 
\caption[]{}\label{tab:X}% 
\centering 
\input{} 
\vspace*{-4mm}%Put here to reduce too much white space after table 
\end{table}

Barplots | Hide empty (value 0) ybars with pgfplots

Source: tex.stackexchange.com

You can use

 y filter/.expression={y==0 ? nan : y}

in the options of \addplot.

\documentclass{article}

% ---------------------------------- tikz
\usepackage{pgfplots}          % to print charts
\pgfplotsset{compat=1.12}

\begin{document}

\begin{figure}
  \centering
  \begin{tikzpicture}
    \begin{axis} [
      % general
      ybar,
      scale only axis,
      height=0.5\textwidth,
      width=1.2\textwidth,
      ylabel={\# Dots},
      nodes near coords,
      xlabel={Variation},
      xticklabel style={
        rotate=90,
        anchor=east,
      },
      %enlarge x limits={abs value={3}},
      ]
      \addplot+[y filter/.expression={y==0 ? nan : y}] table [
        x=grade,
        y=value,
      ] {
grade   value
-11 0
-10 0
-9  0
-8  0
-7  0
-6  0
-5  3
-4  1
-3  2
-2  15
-1  11
0   179
1   8
2   1
3   0
4   1
5   2
6   0
7   0
8   0
9   0
10  0
11  0
      };
    \end{axis}
  \end{tikzpicture}
\end{figure}
\end{document}

enter image description here

Before:

enter image description here

Figures | Positioning of Figures

Source: sharelatex.com

The placement specifier parameter allows us to have a greater control over where a figure is placed. But while LaTeX will do its best to follow the placement we specify, it may not always be possible for it to adhere to it. Let us take a look at different placement specifiers and what they do before we dive into examples.

Specifier Permission
h Place the float here, i.e., approximately at the same point it occurs in the source text (however, not exactly at the spot)
t Position at the top of the page.
b Position at the bottom of the page.
p Put on a special page for floats only.
! Override internal parameters LaTeX uses for determining “good” float positions.
H Places the float at precisely the location in the LaTeX code. Requires the float package (\usepackage{float}). This is somewhat equivalent to h!.
Example
    \begin{figure}[h]
    ... figure contents...
    \end{figure}

Figures, Plots | Split subfigures from pgfplots groupstyle

Source: tex.stackexchange.com

Use \ContinuedFloat to have split plots but keep same figure number.

Example (from source):

\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \setcaptionsubtype
        \begin{groupplot}[%
            ,group style={%
                ,group name=my plots
                ,group size=2 by 3
                ,vertical sep=2cm,
                ,horizontal sep = 2cm,
                ,ylabels at=edge left
                }
            ,width=7cm
            ,height=6cm
            ,try min ticks=5
            ,xlabel={Frequency in \si{\hertz}}
            ,grid=both
            ,every major grid/.style={gray, opacity=0.5}
            ]
            \nextgroupplot%
                \addplot[smooth,blue]{rnd};     
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};    
        \end{groupplot}
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r1.north) {\caption{Plot \arabic{subfigure}\label{subplot:one}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r1.north) {\caption{Plot \arabic{subfigure}\label{subplot:two}}};    
    \end{tikzpicture}
    \caption{Plot showing Absolute Errors.}
\end{figure}
\begin{figure}
    \ContinuedFloat
    \centering
    \begin{tikzpicture}
        \setcaptionsubtype
        \begin{groupplot}[%
            ,group style={%
                ,group name=my plots
                ,group size=2 by 3
                ,vertical sep=2cm,
                ,horizontal sep = 2cm,
                ,ylabels at=edge left
            }
            ,width=7cm
            ,height=6cm
            ,try min ticks=5
            ,xlabel={Frequency in \si{\hertz}}
            ,grid=both
            ,every major grid/.style={gray, opacity=0.5}
            ]   
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};        
            \nextgroupplot%
                \addplot[smooth,blue] {rnd};%
                \addplot[mark=*,red,mark options={scale=.65}] {rnd};        
        \end{groupplot} 
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r1.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:three}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r1.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:four}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c1r2.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:five}}};
        \node[text width=.5\linewidth,align=center,anchor=south] at (my plots c2r2.north) {\caption[]{Plot \arabic{subfigure}\label{subplot:six}}};    
    \end{tikzpicture}
    \caption[]{Plot showing Absolute Errors. (continued)}\label{abserror}
\end{figure}

tcolorbox | Align left column on top

Source: tex.stackexchange.com

Question

I want to align Some text with Lead Programmer like this:

enter image description here

But the leftrulebox (a tcolorbox) inside the description environment doesn’t align properly. The following code gives this:

enter image description here

Solution

I propose a different approach here not using a list to place the labels but reducing the width for the tcolorbox and using an optional argument (it could easily be turned into mandatory) and the overlay key to place the label at a fixed vertical position; since the label is placed inside a node of fixed width and with align=right, they admit line breaking and raggedleft texts (feel free to change the lengths according to your needs):

\documentclass{article}
\usepackage[left=60pt,top=60pt,right=60pt,bottom=60pt]{geometry}
\usepackage{xcolor}
\usepackage{kantlipsum}
\usepackage{enumitem}
\usepackage[many]{tcolorbox}

\setitemize{nolistsep,labelsep=1ex,leftmargin=*}

%% colors---
\definecolor{lightgray}{gray}{0.8}

%%items--
\newlist{items}{description}{1}
\setlist[items]{align=right,font=\normalfont, leftmargin=1.8in,style=nextline,labelsep=1em,}

%% leftrulebox---
\tcbuselibrary{skins,breakable}
\newtcolorbox{leftrulebox}[1][]{
    colback=white,
    left=0.5ex,
    top=0pt,
    arc=0pt,
    outer arc=0pt,
    enlarge left by=1.8in,
    enlarge right by=-\dimexpr1.8in+\parindent\relax,
    right=\dimexpr1.8in+\parindent\relax,
    leftrule=1pt,
    rightrule=0pt,
    toprule=0pt,
    bottomrule=0pt,
    breakable,
    nobeforeafter,
    enhanced jigsaw,
    overlay={
      \node[anchor=north east,inner ysep=0pt,align=right,text width=1.5in] 
        at ([yshift=-0.55ex]frame.north west) {\hfill#1};
    },
    before=\vskip2\itemsep\noindent
  }

\begin{document}

\section*{Objective}

\begin{leftrulebox}[Objective]
\kant[1]
\end{leftrulebox}

\section*{Positions}

\begin{leftrulebox}[1/2010 -- 2/2012]
\textbf{Lead Programmer}, Social Networks Inc \par
Some text \par some text
  \begin{itemize}
    \item Reengineered multiple systems that fueled improvements to productivity, eficiency, uptime and accuracy for global business operations. Developed code, system design and test/QA plans for all solutions and often coordinated the national or international rollout.
    \item Led, architected and participated in the design, testing and deployment of client/server, multi-tier applications, ActiveX and related components.
    \item Developed new procedures for requirements gathering, needs analysis, testing, scripting and documentation to strengthen quality and functionality of business-critical applications.
    \end{itemize}
\end{leftrulebox}

\begin{leftrulebox}[1/2009 -- 2/2010]
\textbf{Programmer I}, The Coolest Search Engine
  \begin{itemize}
    \item Led solutions engineering that involved process automation, macro conversion and functionality enhancement. Replaced time-consuming, error prone manual processes with elegant, automated solutions.
    \item Developed and implemented cross-platform, Java-based POS system. Completed project under budget and three weeks ahead of deadline.
    \item Coded new solutions that increased availability and scalability by 45\% and 75\%, respectively.
\end{itemize}
\end{leftrulebox}

\section*{Skills}

\begin{leftrulebox}[\textbf{Systems}]
\kant[1-2]
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Others}]
some short text here
\end{leftrulebox}

\begin{leftrulebox}[\textbf{Databases}]
some short text here
\end{leftrulebox}

\end{document}

Some images showing the label alignment:

enter image description here

enter image description here

enter image description here

Text, Table | Wrap text around a table

Source: tex.stackexchange.com

The wrapfig package provides this functionality.

\documentclass{article}
\usepackage{wrapfig,lipsum,booktabs}
%------------------------------------------
\begin{document}
This is where the table goes with text wrapping around it. You may 
embed tabular environment inside wraptable environment and customize as you like.
%------------------------------------------
\begin{wraptable}{r}{5.5cm}
\caption{A wrapped table going nicely inside the text.}\label{wrap-tab:1}
\begin{tabular}{ccc}\\\toprule  
Header-1 & Header-1 & Header-1 \\\midrule
2 &3 & 5\\  \midrule
2 &3 & 5\\  \midrule
2 &3 & 5\\  \bottomrule
\end{tabular}
\end{wraptable} 
%------------------------------------------
{\lipsum[2] 
\par
Table~\ref{wrap-tab:1} is a wrapped table.
%------------------------------------------
\end{document}

enter image description here

Source: CTAN.orgWrapfig

Using wrapfig to span multiple columns
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wrapfig can’t automatically make matching cutouts in adjacent columns because it doesn’t know which text will land in just the right place in the column next-door. It certainly can’t handle floating in such situations!

Here are some methods for doing such layout “by hand”. They are
practical for one or a few such figures where you can tweak the
layout for the final copy. It is too painful to do this for long
or frequently-revised documents. If you do have multiple fiddling,
fix the first one in each chapter (or after any forced page break),
rerun, then fix the second, etc.

(These examples use calc.sty to evaluate overhangs in place.)

Cutouts in Matching Columns

~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~X ~~~~~~~~~~~~~~~~~Y
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

Initially, write the document without the wrapfigure, and locate the
desired natural linebreak at “X”. (This first step is used for all
methods described here.) Then change to

~~~~~~~~X
\begin{wrapfigure}[6]{r}[.5\width+.5\columnsep]{6cm}

\end{wrapfigure}
~~~~….

and run LaTeX again. This will print the figure overlapping the right
column, but no matter. Use this run to locate position “Y” in the text.
For the final run, switch to:

~~~~~~~~X
\begin{wrapfigure}[6]{r}[.5\width+.5\columnsep]{6cm}

\end{wrapfigure}
~~~~….
…~~~~~~~Y
\begin{wrapfigure}[6]{l}[.5\width+.5\columnsep]{6cm}
\vfill
\end{wrapfigure}
~~~~~~~~~~~

Taking a whole column plus a cutout

~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~X ~~~~~~~~~~~~~~~~~Y
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

Locate “X” first, without any figure, as above, then write the
document like:

~~~~~~~~X
\begin{wrapfigure}[6]{r}[\columnwidth+\columnsep]{9cm}

\end{wrapfigure}
~~~~….

and ignore the overprinting of the right column. Then, after locating
“Y” in the text, switch to:

~~~~~~~~X
\begin{wrapfigure}[6]{r}[\columnwidth+\columnsep]{9cm}

\end{wrapfigure}
~~~~….
…~~~~~~~Y\vspace{6\baselinskip}
~~~~~~~~~~~
for the final layout

a whole column preceding a cutout

~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~X ~~~~~~~~~~~~~~~~~Y
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

After locating “X”, write the draft document like:

~~~~~~~~X\vspace{6\baselinskip}
~~~~….
~~~~~~~~~~~~~
~~~~~~~~~

run LaTeX to locate “Y”, and then switch to:

~~~~~~~~X\vspace{6\baselinskip}
~~~~….
~~~~~~~~~~~~~Y
\begin{wrapfigure}[6]{l}[\columnwidth+\columnsep]{9cm}

\end{wrapfigure}
~~~~~~~~~

Spanning (parts of) three columns

~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~X ~~~~~~~~~~~~~~~~~Y ~~~~~~~~~~~~~~~~~Z
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~ ~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

This uses a combination of the above. First locate X, then use

~~~~~~~~X
\begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}

\end{wrapfigure}
~~~~….

Locate Y from this, and change to

~~~~~~~~X
\begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}

\end{wrapfigure}
~~~~….
~~~~~~~~~~~~Y\vspace{6\baselineskip}
~~~~~~~….

which allows you to locate Z, to end up with

~~~~~~~~X
\begin{wrapfigure}[6]{r}[.5\width+.5\columnwidth+\columnsep]{12cm}

\end{wrapfigure}
~~~~….
~~~~~~~~~~~~Y\vspace{6\baselineskip}
~~~~~~~….
~~~~~~~~~~~~Z
\begin{wrapfigure}[6]{l}[.5\width+.5\columnwidth+\columnsep]{12cm}
\vfill
\end{wrapfigure}

(Of course, to do matching cut-outs properly requires typesetting
the text to a grid.)

Blog at WordPress.com.

Up ↑