## [LaTeX] Optional parameters explained for fine tuning the placement of tables and figures in LaTeX

This post introduces the optional parameters to fine tune the placement of tables and figures in LaTeX.

If you are using LaTeX, you have seen figure examples like the following

\begin{figure}[ht]
...
\end{figure}

These are optional parameters to fine tune the placement of tables and figures, the term is Float placement specifiers (introduced in detail below). LaTeX will try to honor the placement with respect to the actual place, the top or bottom of the page, or a separate page of floats coming immediately after the present insertion point.

### Float placement specifiers

To direct a float to be placed into one of these areas, a float placement specifier has to be provided as an optional argument to the float.

If no such optional argument is given then a default placement specifier is used, which depends on the float class. Each float in LaTeX belongs to a class. By default, LaTeX knows about two classes,figureand table. A float placement specifier can contain the following characters in any order and combination:

• ! — indicates that some restrictions should be ignored
• h — indicates that the float is allowed to be placed inline (i.e., here)
• t — indicates that the float is allowed to go into a top area
• b — indicates that the float is allowed to go into a bottom area
• p — indicates the the float is allowed to go on a float page or column area

The order in which these characters are stated does NOT influence how the algorithm tries to place the float (e.g., [ht] or [th] will make no difference)! This is one of the common misunderstandings, for instance when people think that bt means that the bottom area should be tried first. You may also force LaTeX to “insist” on these specifications by adding an exclamation mark (!) before the placement parameters, e.g. \begin{figure}[!htb].

However, if a letter is not present then the corresponding area will not be tried at all.

For more detailed intro about this topic, check out How to influence the position of float environments like figure and table in LaTeX?

References:

## How to remove the double quotes in a CSV file on Ubuntu

This post introduces the simplest way to remove all double quotes in a csv file on Ubuntu (via terminal).

If you have a CSV file like

#input.csv
"1,2,3,4,9"
"1,2,3,6,24"
"1,2,6,8,28"
"1,2,4,6,30"


and want something like

#output.csv
1,2,3,4,9
1,2,3,6,24
1,2,6,8,28
1,2,4,6,30

Or you have something like this

and want something like this

cd to the directory where input.csv file is located and then issue the following command:

$tr -d '"' <input.csv> output.csv Note: tr stands for translateThe d flag causes tr command to delete all tokens of the specified set of characters from its input. References: tr (Unix) ## How to install Visual Studio Code text editor on Ubuntu 16.04 This post introduces how to install the nice text editor Visual Studio Code on Ubuntu. Step 1: Install gdebi Open a terminal and type the following command into your terminal. $ sudo apt-get install gdebi
# use gdebi tool to install external *.deb packages like Visual Studio Code and Google Chrome.
# gdebi will automatically fetch and install all Visual Studio Code dependencies.

In your terminal, cd to the directory where you downloaded the file (for example, in my case, it is in my Downloads folder.)

Step 3: Install Visual Studio Code

$sudo gdebi code_1.15.1-1502903936_amd64.deb # your downloaded version might be different from mine, so change it to #your .deb file Step 4: Click “Search your computer” icon on your tool bar, and type in Visual Studio Code, you will see it’s installed on your Ubuntu. Step 5: Right click the Visual Studio Code icon on your tool bar and pick Lock to Launcher, your are ready to use your Visual Studio Code editor on your Ubuntu 16.04:) ## How to install Google Chrome Browser on Ubuntu 16.04 This post introduces how to install Google Chrome Browser on Ubuntu 16.04. Step 1: Install gdebi Open a terminal and type the following command into your terminal. $ sudo apt-get install gdebi
# use gdebi tool to install external *.deb packages like Google Chrome.
# gdebi will automatically fetch and install all Chrome dependencies.

$wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb # use wget command to download a latest version of the Google Chrome browser Step 3: Install Google Chrome $ sudo gdebi google-chrome-stable_current_amd64.deb

Step 4: Click “Search your computer” icon on your tool bar, and type in Chrome, you will see it’s installed on your Ubuntu.

Step 5: Right click the Chrome icon on your tool bar and pick lock to Launcher, your are ready to use your Google Chrome on your Ubuntu 16.04:)

## [LaTeX] Use fancyhdr package to control page numbering style

This post introduces how to use fancyhdr package to control page numbering style in your LaTex document.

We can use the LaTeX package fancyhdr to customize how the page numbers are displayed.

For example, if you want to put the current page number in the context of the page numbers in the whole document (page 1 of 10 or 1/10), the following command can help you with that:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lastpage}

\pagestyle{fancy}
\fancyhf{}

%use the following commands by uncomment (i.e., remove the % for the line you want to use.)

%uncomment the command below (the part in bold) if you want to show the %style "Page 1 of 10" to the right of your footer)
%\rfoot{Page \thepage \hspace{1pt} of \pageref{LastPage}}
% change \rfoot to \lfoot or \cfoot for left or center positioning

%uncomment the command below (the part in bold) if you want to show the style "1/10" to the right of your footer)
%\rfoot{\thepage \hspace{1pt}/\pageref{LastPage}}
% change \rfoot to lfoot or \cfoot for left or center positioning

%uncomment the command below (the part in bold) if you only want to put %the current page number at the center of the header
% change [C] to [R] or [L] for right or left positioning

\begin{document}

\tableofcontents

\section{First section}
Some text...

\section{Second section}
More text...

\end{document}



See the references given below for more style needs (e.g., even and odd page numbering).

References:

Page numbering/ Customizing numbering styles

LaTeX/Customizing Page Headers and Footers

## Screenshot tools for Ubuntu and Windows

This post introduces some handy screenshot tools for Ubuntu and Windows.

======Ubuntu

One of the powerful screenshot tool, which not only allow you to take screenshot, of any part of screen, but also allows you to edit the captured image, adding text, hiding private content by pixelating, upload an image to a hosting site and much more.

Gimp is a free and open source image editor which can be used for image manipulation, editing, resizing, retouching etc.

When you’ll open the Gimp GUI, go to File -> Create Screenshot and this menu will appear and you can select the option you want, whether to take screenshot of whole or part of screen.

After this, the snap of image created will be available on the GUI for editing, where you can edit the image, apply effects and so on.

(See the references section for more options for Ubuntu.)

======Windows

FastStone Capture works on XP, Vista, Windows 7, Windows 8.x and Windows 10.

References:

## Usage tips for Google docs and sheets

This post provides some useful tips for Google Docs and Sheets.

======Google doc related tips

• Add outline (show outline)

• Print a Google Doc with Comments

File / Download As / Web Page

An HTML file will be downloaded onto your computer. Open that HTML file in a web browser and you will see the text of the Google Document with footnotes for each of the comments. you can print this html file as pdf, and it will have comments at the end of your pdf file.

• Change the default style of headings in Google doc

I do not like the default heading style in Google doc, so I would like to change it to my preferred heading styles. See below for the steps of how to do that:

• Open a Google doc
• Select the text of Heading 1, and change the style (e.g., Times new roman, font size, bold) you prefer for Heading 1

• Go to the menu Format/Paragraph styles / Heading 1/ Update ‘Heading 1’ to match (see the pic below)

You will see all the Heading 1 format updated as the one you set above. Do the same for the rest levels of headings.

• If you want to make the heading style that you have set just now the default one for Google docs, be sure to use Format/Paragraph styles /Options/Save as my default styles (see the pic below).

• Interactive Checklists in Google Docs

See below for the steps about how to create interactive checklists in your Google docs.

• Type the items — each item per line.
• Select all the lines of items.
• Click the down arrow to the right of the “Bulleted list” icon in the toolbar, and then choose the checkbox option from the pop-out menu.

• Alternately, we can click “Format” in the menu, then “Lists”, then “Bulleted list”, and finally choose the checkbox option.

• This will place a checkbox before each line in the list.

See the steps below for how to mark the checklist off  when we complete them. This can be done by changing a checkbox to a checkmark.

• Left-click  on a checkbox — the entire group of checkboxes will be selected.
• Left-click again on the same checkbox — this will allow us to just select the single checkbox we have clicked.
• Right-click on that checkbox.
• A window will pop up, click and choose the check mark (shown in red box in the pic below)

• The empty checkbox will now be replaced with a check mark sign, indicating the item has been completed.

• Repeat as needed for the rest of checkboxes.

• Freeze or unfreeze columns & rows in your Google spreadsheet
1. Open a spreadsheet and select a cell in a row or column you want to freeze.
2. Open the View menu.
3. Hover over Freeze.
4. Select one of the options to freeze up to ten rows, or five columns.

References:

## Find IP address on Ubuntu

This post introduces how to find the IP address on your Ubuntu.

Open your terminal (CTRL + ALT + T), and then issue the following command.

$ifconfig | less your IP should be listed under inet addr Something looks like this: inet addr:10.0.5.25 Bcast: 10.0.5.255 Mask:255.255.255.0 In this example, 10.0.5.25 would be your IP address. Note: press “q” to exit. ## Some interesting facts about number 0 and 9 Zero is the most complex number among 0-9. It can be nothing, and can also be something that expands other number. For example, append 0 after 1, it expands 1 to another larger number 10. Number 1-9 just can be something. They don’t expend other number. Another interesting fact: (I bet most of us know about the first fact, but maybe not the second one…) • Any number times 0 goes back to 0 itself. • Any number times 9 goes back to 9 itself, no exception. 2*9 = 18 (1+8 = 9) 7*9 = 63 (6+3 = 9) 99*9 = 891 (8+9+1 = 18 –> 1+8 = 9) 836*9 = 7524 (7+5+2+4 = 18 –> 1+8 = 9) 2017*9 = 18153 (1+8+1+5+3 = 18 –> 1+8 = 9) 25379*9 = 228411 (2+2+8+4+1+1 = 18 –> 1+8 =9) After I noticed this interesting fact, I did a search on the Internet. Why is it that if you multiply any number by nine and add up the digits of the product, they also equal nine? For example 9×12=108. 1+0+8=9 ## Use latexdiff to compare different versions of LaTeX tex files to visually mark differences This post introduces how to use latexdiff to compare two versions of latex *.tex files, in order to visually mark changes to tex files. (One colleague asked me about the usage of latexdiff, so I think it is a good time to write it up into a blog post to share with those who need some help with this.) latexdiff is a Perl script and requires an installation of Perl 5.8 or higher. Use latexdiff to mark differences and create a new LaTeX document with markup differences between two latex files. • Linux (Ubuntu) users latexdiff can be found in Ubuntu repository and detailed description of usage can be found here. In your terminal, issue the commands below to install latexdiff. sudo apt-get update sudo apt-get install latexdiff  # open your terminal, and cd to the tex files you need to compare # issue the following command latexdiff original_version.tex revised_version.tex > diff.tex Run the diff.tex file like you run a normal tex file, you will see beautifully marked differences in the pdf file. • Mac OS X users latexdiff is a Perl script and requires an installation of Perl 5.8 or higher. Mac OS X includes an installation of Perl and no additional setup is required. latexdiff can be found in any CTAN repository (If you are using MacTex on your mac, latexdiff is already installed in MacTex under /usr/texbin/latexdiff. No need to install it separately. To use latexdiff in commend line, see below) After you setting perl and latexdiff, just open your terminal, and cd to the path where you put you two versions of latex tex files, and then issue the command. (If the two tex files are located in different location, you can just give the relative path to that location for each version of tex file.) $ latexdiff original_version.tex revised_version.tex > diff.tex
will compare original_version.tex to revised_version.tex and create a new file diff.tex showing the differences.
Run the diff.tex file like you run a normal tex file, you will see beautifully marked differences in the pdf file.
• Online latexdiff
when you get the diff.tex on the online latexdiff, you can paste into a new tex file and then you can run it and you will see the pdf which shows the differences.
• Multiple tex files for each version

If each version of your text files contains multiple (sub) tex files or if you want to use latexdiff with Git, check the reference lists for potential solutions.

References:

LATEXDIFF: SUPERB DIFF TOOL FOR LATEX (pdf) — talks about solutions to multiple files, but this can only deal with sub-files on the same level, not nested cases.

Two LaTeX gems: ShareLaTeX and latexdiff (pdf)

Using Latexdiff For Marking Changes To Tex Documents (pdf)

Multiple-file LaTeX diff (pdf— this one is very good. – use python code to merge multiple tex files to one big tex file for each version and then use latexdiff to make comparision.

Latexdiff with subfiles (pdf) — this one talks about solutions to multiple tex files.

Using latexdiff with git (pdf) – Git Latexdiff  — this is about using git together with latexdiff

Git and latexdiff: compare versions of LaTeX documents (pdf) — this is also about using git together with latexdiff