Miscellaneous
Some (maybe) useful tools
Create booklet from PDF
Use pdfbook2
:
pdfbook2 --paper=a4paper --inner-margin=100 file.pdf
You can use options for the --out-margin
as well as for top
and bottom
.
Note: if you preview the output pdf, odd pages will be upside-down.
That’s what you want if you print settings are
Two sided: Long Edge (Standard), Pages per side: 1.
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.
biblatex/biber
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.
latexdiff-git
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: compare two 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
To rebase interactively the last 2 commits (from HEAD), or to squash the last commit
git rebase -i HEAD~2
git: worktree
Add a new worktree tracking an existing remote branch:
git worktree add <path> <remote>/<branch>
Use -b <new_branch>
to track the worktree in a local branch.
See my answer on stackexchange.
git: delete remote branch
Simply git psuh
with a -d
flag, then specify the name of the remote branch:
git push -d origin branch
TableMode
Tables in Emacs
Run:
M-x table-insert
and fill the table.
When you are done, use
M-x table-generate-source
to generate code in HTML, LaTeX, Wiki and Mediawiki, and more.
Magit
Use git inside Emacs.
Run:
M-x magit-status
to see git status. From the status buffer you can:
- stage files with
s
, or withM-x magit-stage-file
- commit your changes with
c c
(type the message thenC-c C-c
to actually commit), - do a git push
P u
or a git pullF u
.
Rebase commits marked with !squash
automatically with M-x magit-rebase-autosquash
.
You can use F
– (“Instant Fixup”) to performs a rebase after creating the !fixup
commit.
See emacs.stackexchage
Emerge
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.
Pandoc
Convert epub in PDF.
pandoc -f epub -t latex --latex-engine=xelatex file.epub -o file.pdf
Other format and options in the manual.
rsync
Sync a local folder with a remote one. ( See unix.stackexchange )
rsync -auv "source_folder/" "user@<source>:<dest_dir>/"
Copy files for backup.
rsync -gloptrunc $srcdir $dstdir
A brief guide, from serverfault.com:
g
- preserve group ownership infol
- copy symlinks as symlinkso
- preserve owner infop
- preserve permissionst
- preserve timestampsr
- recurse thru directoriesu
- update, skip any newer files- [
n
] - no, dont do this, do a dry run instead c
- checksum, attempt checksums on file blocks when possible (*) note: on local filesystems, this get overridden and entire files are copied instead.v
- verbose
Change PDF metadata
From command line:
exiftool -Title="This is the Title" -Author="Happy Man" -overwrite_original file.pdf
See askubuntu. My friend Andrea had developed a user friendly GUI for this task.
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"
done
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 tex.stackexchange.
Convert SVG to PDF
Use Inkscape in a shell:
inkscape file.svg --export-area-drawing --batch-process --export-type=pdf --export-filename=output.pdf
See graphicdesign.stackexchange.
See also Pavel Zorin-Kranich page about $\LaTeX$ tools and best practice
Suggestions on How to write maths.
Other useful tools
- arxiv-collector: collect files to upload on the arXiv.
reMarkable
Scripts for the reMarkable are here
This website is powered by HUGO with the minimal-bootstrap-hugo-theme .