Blog

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

Text | X mark to match checkmark

Source: tex.stackexchange.com

I would think your best bet might come from pifont‘s dingbats:

\checkmark and (\cmark + \xmark)

\documentclass{article}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\begin{document}
\verb|\checkmark|: \checkmark \par
\verb|\cmark|: \cmark \par
\verb|\xmark|: \xmark
\end{document}

\cmark is defined as \ding{51}, while \xmark is defined as \ding{55}. Here is a list of the dingbat symbols, taken from the pifont quick reference guide:

pifont quick reference guide

TeXnicCenter & Adobe Reader DC

Source: tex.stackexchange.com

Problem: error “Can not execute the command” shows up and the PDF is not generated.

error TeXnicCenter

Solution

Can be solved by proper setting in TeXnicCenter:

  1. Go to menu: “Build”-> “Define Output Profiles.”
  2. choose profile “LateX to PDF”.
  3. Switch to “Viewer” tab
  4. Set-up parameters:

“Executable path” should be something like (check, where have you installed Adobe Reader):

    C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe

Parameters: “Command”, “Server” and “Topic” appears three-times on settings page – be sure to change ALL three appearence correctly.

“Server” parameter should be always:

acroviewR17

(For earlier version of Adobe, it should be acroviewR15).

“Topic” parameter should be always:

control

“Command” parameter should be twice:

[DocOpen("%bm.pdf")][FileOpen("%bm.pdf")]

Last instance of “Command” parameter (in “close document…” section) should be:

[DocClose("%bm.pdf")]

After setting everything, confirm “Profiles” dialog and it is done.

Or just check following snapshot of settings

enter image description here

 

Text | Short underscore

Source: tex.stackexchange.com

Redefine the length of your underscore:
\renewcommand{\_}{\textscale{.7}{\textunderscore}}

Or: \newcommand{\smallunderscore}{\textscale{.5}{\textunderscore}}

 
Source: tex.stackexchange.com

In a fix-width font every symbol should have the same width. So a long underscore is a bit unusual. In any case: in OT1-encoding (which you are obviously using) \_ calls internally \textunderscore, which in turn is define as a rule of width 0.3em and some space. You can redefine \_ to get a longer rule and use \textunderscore at other places:

\documentclass{book}
\DeclareTextCommand{\_}{OT1}{%
  \leavevmode \kern.06em\vbox{\hrule width.6em}}

\begin{document}
a\textunderscore b  {\ttfamily a\_b}
\end{document}

example

 

Text | Subscript in text mode

Source:tex.stackexchange.com

Use \textsubscript{}. Or in math mode: $_\text{}$.

Note that \textsubscript enters math mode as well. This might produce problems in PDF strings where math is not allowed, for instance in bookmarks. If you used hyperref and simply used \textsubscript in a section heading, hyperref would complain about the math shift. The command \texorpdfstring comes to the rescue:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\section{\texorpdfstring{like\textsubscript{this}}{like this}}
\end{document}

That applies to math and math symbols in sectioning headings of course as well.

 

Plots | One title over subplots

Source: tex.stackexchange.com

enter image description hereYou can use a TikZ node as a title for a quick solution.

 

 

 

 

 

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{tikzpicture}
  \begin{groupplot}[group style={group size=2 by 2},height=3cm,width=3cm]
    \nextgroupplot[title=One]
    \addplot coordinates {(0,0) (1,1) (2,2)};
    \nextgroupplot[title=Two]
    \addplot coordinates {(0,2) (1,1) (2,0)};
    \nextgroupplot[title=Three]
    \addplot coordinates {(0,2) (1,1) (2,1)};
    \nextgroupplot[title=Four]
    \addplot coordinates {(0,2) (1,1) (1,0)};
  \end{groupplot}
\node (title) at ($(group c1r1.center)!0.5!(group c2r1.center)+(0,2cm)$) {THE Title};
\end{tikzpicture}
\end{document}

Create a free website or blog at WordPress.com.

Up ↑