Some (maybe) useful tools

Increase contrast in a PDF

Convert PDF pages to individual images

convert -density 600 your_pdf_filename.pdf  output-%02d.jpg

Adjust image quality

convert output*.jpg -normalize -threshold 80% final-%02d.jpg

If you want a pdf back:

convert final*.jpg my_new_highcontrast.pdf

See superuser.com for more links and comments.

Compress (multiple) images

To compress one image:

convert image.jpg -quality 50% image-compressed.jpg

To compress all images in the folder where you are (output of pwd)

for i in *; do convert $i -quality 50% $i-out.jpg ; done;

See askubuntu.

Compress PDF

Assuming that these are PDF containing only large images, this works well:

ps2pdf -dPDFSETTINGS=/ebook input.pdf output.pdf

The other options for dPDFSETTINGS are: /screen lower quality, smaller size. (72 dpi)

/ebook for better quality, but slightly larger pdfs (150 dpi)

/prepress output similar to Acrobat Distiller “Prepress Optimized” setting (300 dpi)

/printer selects output similar to the Acrobat Distiller “Print Optimized” setting (300 dpi)

/default selects output intended to be useful across a wide variety of uses (possibly larger output)

Grayscale output

To generate a PDF in grayscale (useful for printing) in $\LaTeX$

\usepackage{xcolor}             % for output 
\selectcolormodel{gray}         % in grayscale 

Note: external figures will stay in their original colour. See TeXstackexchange and latex.org.

Break display equations on multiple pages

Use the command \allowdisplaybreaks, see this for more options.

The environments split and aligned should prevent a block from page breaks.


You can keep your bibliography in a single .bib file in a separated repository, and include it via git submodule in each of your project. Here are some reasons for which you may wish to do so.

biber supports multiple keys: they are called IDS, see this question.


Generate a PDF to view diff on LaTeX source between commits. For example:

latexdiff-git --revision e26bbec file.tex

where you want to replace e26bbec with your commit hash.

Use --flatten if you are including other sources with \input or \include in your TeX.

git: difference between commits

Run git show to see the difference between HEAD and the last commit. Run

git diff HEAD~3        (diff between working tree  and the last 3 commits)
git diff HEAD~3 HEAD   (diff between     HEAD      and the last 3 commits)

Note: git show = last commit log + git diff HEAD~1 HEAD. Use

git show HEAD file.tex

to show the difference for a single file. See stackoverflow

git: history around a line

For the chunk of lines: 313 – 316 for example:

git log --topo-order --graph -u -L313,316:file.tex

git: rebasing

To rebase a branch onto master, first checkout the branch

git checkout brach_to_rebase

from there, tell git where to rebase it, for example:

git rebase master


Use git inside Emacs.

Run: M-x magit-status to see git status. From the status buffer you can:

  • stage files with s , or with M-x magit-stage-file
  • commit your changes with c c (type the message then C-c C-c to actually commit),
  • do a git push P u or a git pull F u.


Merge two file in Emacs.

Run: M-x emerge-files and choose the two files. Then use the following shortcuts:

  • Next difference with n,
  • Previous difference with p

For a difference, you can choose: the A version (left) with a and the B version (right) with b.

Use q to quit and then save the merge (buffer) in a file.


Convert epub in PDF.

pandoc -f epub -t latex --latex-engine=xelatex file.epub -o file.pdf

Other format and options in the manual.


Sync a local folder with a remote one.

rsync -auv "source_folder/" "user@<source>:<dest_dir>/"

See unix.stackexchange

Change PDF metadata

From command line:

exiftool -Title="This is the Title" -Author="Happy Man" -overwrite_original file.pdf

See askubuntu

Roughly count words in a PDF

pdftotext myfile.pdf - | wc -w

See this question on superuser for more options.

Count words in a $\TeX$ or $\LaTeX$ file

Use texcount:

texcount -1 -sum -inc file.tex
  • -inc to parse files called with \include and \input,
  • -sum to show the total
  • -1: Same as specifying -brief and -total, to ensure only one output line. Used with -sum to print the total number only.

See the texcount manual.

Convert multiple files

for f in /path/*.jpg /path/*.JPG; do
    convert "$f" "${f%.*}.gif"
See askubuntu

Convert doc to pdf

lowriter --convert-to pdf file.doc

See askubuntu

Convert SVG to TeX

Include it directly or use Inkscape in a shell:

inkscape -D -z --file=image.svg --export-pdf=image.pdf --export-latex

See askubuntu.

See also Pavel Zorin-Kranich page about $\LaTeX$ tools and best practice

Suggestions on How to write maths.

Other useful tools


Scripts for the reMarkable are here

This website is powered by HUGO with the minimal-bootstrap-hugo-theme .