Commands tagged latex (9)

  • This is an example of the usage of pdfnup (you can find it in the 'pdfjam' package). With this command you can save ink/toner and paper (and thus trees!) when you print a pdf. This tools are very configurable, and you can make also 2x2, 3x2, 2x3 layouts, and more (the limit is your fantasy and the resolution of the printer :-) You must have installed pdfjam, pdflatex, and the LaTeX pdfpages package in your box. Show Sample Output


    3
    pdfnup --nup 2x1 --frame true --landscape --outfile output.pdf input.pdf
    TetsuyO · 2010-12-21 14:20:06 5
  • If the pdf/dvi/etc documentation for a latex package is already part of your local texmf tree, then texdoc will find and display it for you. If the documentation is not available on your system, it will bring up the package's webpage at CTAN to help you investigate. Show Sample Output


    2
    texdoc packagename
    bwoodacre · 2010-05-23 20:02:32 7

  • 1
    grep -R usepackage * | cut -d']' -f2 | cut -s -d'{' -f 2 | sed s/"}"/.sty"}"/g | cut -d'}' -f1 | sort | uniq | xargs dpkg -S | cut -d':' -f1 | sort | uniq
    prayer · 2010-05-22 19:37:26 4

  • 1
    dwdiff -c a.tex b.tex | less -R
    fubunny · 2011-07-27 15:24:35 4
  • It is often recommended to enclose capital letters in a BibTeX file in braces, so the letters will not be transformed to lower case, when imported from LaTeX. This is an attempt to apply this rule to a BibTeX database file. DO NOT USE sed '...' input.bib > input.bib as it will empty the file! How it works: /^\s*[^@%]/ Apply the search-and-replace rule to lines that start (^) with zero or more white spaces (\s*), followed by any character ([...]) that is *NOT* a "@" or a "%" (^@%). s=<some stuff>=<other stuff>=g Search (s) for some stuff and replace by other stuff. Do that globally (g) for all matches in each processed line. \([A-Z][A-Z]*\)\([^}A-Z]\|},$\) Matches at least one uppercase letter ([A-Z][A-Z]*) followed by a character that is EITHER not "}" and not a capital letter ([^}A-Z]) OR (|) it actually IS a "}", which is followed by "," at the end of the line ($). Putting regular expressions in escaped parentheses (\( and \), respectively) allows to dereference the matched string later. {\1}\2 Replace the matched string by "{", followed by part 1 of the matched string (\1), followed by "}", followed by the second part of the matched string (\2). I tried this with GNU sed, only, version 4.2.1. Show Sample Output


    1
    sed '/^\s*[^@%]/s=\([A-Z][A-Z]*\)\([^}A-Z]\|},$\)={\1}\2=g' literature.bib > output.bib
    michelsberg · 2013-01-15 22:24:17 10
  • LaTeX is not a smart compiler - You need to run it several times to make it back-patch all the missing refs. The message if to do so or not is buried in its endless output and the log file. This grep lines helps to find it.


    0
    egrep "(There were undefined references|Rerun to get (cross-references|the bars) right)" texfile.log
    gwiener · 2009-07-07 06:48:03 6
  • kpsewhich is a tool for path and file lookup. It is a front-end of the kpathsea library. For one or more given package or file names it returns the complete path from within the TeX installation, that one which the compiler would actually use. Via backticks we can use it as argument to less, more, or any editor. For example: gedit `kpsewhich hyperref.sty` Show Sample Output


    0
    less `kpsewhich scrartcl.cls`
    Stefan · 2012-04-15 11:10:41 3
  • Uses zsh globbing syntax to safely remove all the files known to be generated by LaTeX, but only if there is actually a .tex source file with the same basename present. So we don't accidentally delete a .nav .log or .out file that has nothing to do with LaTeX, e/'[[ -f ${REPLY:r}.tex ]]'/ actually checks for the existance of a .tex file of the same name, beforehand. A different way to do this, would be to glob all *.tex files and generate a globbing pattern from them: TEXTEMPFILES=(*.tex(.N:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(.N)'/)) ; rm -v ${~TEXTEMPFILES} or, you could use purge() from grml-etc-core ( http://github.com/grml/grml-etc-core/blob/master/usr_share_grml/zsh/functions/purge )


    0
    rm -v *.(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(.e/'[[ -f ${REPLY:r}.tex ]]'/)
    xro · 2012-09-18 20:49:28 8
  • List all font names installed in the system. Useful for TeX. Show Sample Output


    0
    fc-list | cut -d':' -f2 | sort -u
    smarx · 2015-12-29 12:23:11 11

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Adequately order the page numbers to print a booklet
Useful if you don't have at hand the ability to automatically create a booklet, but still want to. F is the number of pages to print. It *must* be a multiple of 4; append extra blank pages if needed. In evince, these are the steps to print it, adapted from https://help.gnome.org/users/evince/stable/duplex-npage.html.en : 1) Click File ▸ Print. 2) Choose the General tab. Under Range, choose Pages. Type the numbers of the pages in this order (this is what this one-liner does for you): n, 1, 2, n-1, n-2, 3, 4, n-3, n-4, 5, 6, n-5, n-6, 7, 8, n-7, n-8, 9, 10, n-9, n-10, 11, 12, n-11... ...until you have typed n-number of pages. 3) Choose the Page Setup tab. - Assuming a duplex printer: Under Layout, in the Two-side menu, select Short Edge (Flip). - If you can only print on one side, you have to print twice, one for the odd pages and one for the even pages. In the Pages per side option, select 2. In the Page ordering menu, select Left to right. 4) Click Print.

doing some floating point math

Open a file in a GTK+ dialog window
I use zenity because it's a rewrite of gdialog and also replaces gmessage and has more useful options. Using --text-info allows you to select and copy the text to your clipboard. To see a file in a list dialog: cat /etc/passwd | zenity --width 800 --height 600 --list --column Entries If you don't have zenity, you'll have to download it via apt-get install zenity, etc.

find the biggest files recursively, no matter how many
This command will find the biggest files recursively under a certain directory, no matter if they are too many. If you try the regular commands ("find -type f -exec ls -laSr {} +" or "find -type f -print0 | xargs -0 ls -laSr") the sorting won't be correct because of command line arguments limit. This command won't use command line arguments to sort the files and will display the sorted list correctly.

List programs with open ports and connections
I prefer to use this and not the -n variety, so I get DNS-resolved hostnames. Nice when I'm trying to figure out who's got that port open.

Create a zip archive excluding all SVN folders

Recursively chmod all dirs to 755 and all files to 644

online MAC address lookup

multiline data block parse and CSV data extraction with perl
extract data in multiline blocks of data with perl pattern matching loop

Number of CPU's in a system
this works for a Linux based system, other UNIX systems may have other way(s) to check the number of CPUs.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: