It took me a long time to find out how to use cleveref and amsthm together. If you have texdoc installed, you can find pretty much the same info in the documentation for cleveref. First off, you'll need the package aliascnt. Then you use an alias for the thm counter (or whatever you're using). An example follows:
\usepackage{amsthm} \usepackage{aliascnt} \usepackage{cleveref} \newtheorem{thm}{Theorem}[section] \crefname{thm}{theorem}{theorems} \Crefname{thm}{Theorem}{Theorems} \newaliascnt{lemma}{thm} \newtheorem{lemma}[lemma]{Lemma} \aliascntresetthe{lemma} \newaliascnt{prop}{thm} \newtheorem{prop}[prop]{Proposition} \aliascntresetthe{prop} \crefname{prop}{proposition}{propositions} \Crefname{prop}{Proposition}{Propositions}To test the thing out, try it with this.
\begin{thm} \label{1} A very important statement. \end{thm} \begin{lemma} \label{2} A less important statement. \end{lemma} \begin{prop} \label{3} $1=0$. \end{prop} \cref{1} \Cref{1}\\ \cref{2} \Cref{2}\\ \cref{3} \Cref{3}
Here, I explain how to incorporate pictures created using xfig into a LaTeX document. More instructions can be found here.
If you want both pdf and dvi coming from the same document, then the packages ifpdf and ifthen are pretty useful:
\usepackage{ifpdf} \usepackage{ifthen}Next you'll need some graphic packages:
\ifpdf \usepackage[pdftex]{graphicx,color} \else \usepackage{graphicx} \fiNow, draw your favorite graph of whatever using xfig and export as Combined PS/LaTeX (both parts) as well as Combined PDF/LaTeX (both parts). This produces a bunch of files, all of which are best kept in the folder containing the .tex document (or wherever else you prefer). Now you can define a handy command
\newcommand{\mynd}[4] { \begin{figure}[#2] \begin{center} \ifpdf \input{#1.pdf_t} \else \input{#1.pstex_t} \fi \ifthenelse{\equal{#3}{}} { } { \caption{#3\label{#4}} } \end{center} \end{figure} }This way, you can import a picture into a latex document which works for both latex and pdflatex. It takes four arguments, these are: #1 the name of the xfig file with no extension; #2 any of the letters h, t, b, etc for your preference of setting the picture here, top, bottom, etc; #3 the caption of the figure—if left empty there will be no caption and no label; #4 the label identifying the picture. For correct configuration of xfig, see section below.
To automate the task of exporting the files as above, make sure that transfig is properly installed (this provides fig2dev) and keep the following script handy.
for i in *.fig do j=`echo $i | sed s/.fig$//` if [ -e $j.pstex_t ] then echo "Overwriting $j.pstex_t" else echo "Creating $j.pstex_t" fi echo "\begin{picture}(0,0)%" > $j.pstex_t echo "\includegraphics{$j.pstex}%" >> $j.pstex_t echo "\end{picture}%" >> $j.pstex_t fig2dev -L pstex_t $j.fig >> $j.pstex_t if [ -e $j.pdf_t ] then echo "Overwriting $j.pdf_t" else echo "Creating $j.pdf_t" fi echo "\begin{picture}(0,0)%" > $j.pdf_t echo "\includegraphics{$j.pdf}%" >> $j.pdf_t echo "\end{picture}%" >> $j.pdf_t fig2dev -L pstex_t $j.fig >> $j.pdf_t if [ -e $j.pstex ] then echo "Overwriting $j.pstex" else echo "Creating $j.pstex" fi fig2dev -L pstex $j.fig > $j.pstex if [ -e $j.pdf ] then echo "Overwriting $j.pdf" else echo "Creating $j.pdf" fi fig2dev -L pdftex $j.fig > $j.pdf done
It can also happen that this stuff doesn't compile into dvi if some text has some color. Typically, the text has color 'black', and manually changing everything to the color 'default' makes it work. However, this is a super boring way of solving a problem, when the following command will do the job:
for i in *.pstex_t; do cat $i | sed s/.color.rgb..0,0,0.// > $i.old; mv $i.old $i; done
The following defines an environment for lists where the numbers and the content all line up nicely with the rest of the material. This is especially convenient to list out examples or remarks, where each element of the list is typically a full paragraph, rather than just a word or two.
\newenvironment{blist} { \begin{list}{(\thedummy)} { \setlength\labelsep{4pt} \setlength\itemindent{4pt} \setlength\leftmargin{0pt} \setlength\labelwidth{0pt} \setlength\parsep{0pt} \usecounter{dummy} } } { \end{list} }The number 4 here can be adjusted, but to me it seems to produce reasonable space. With the above code in the preamble, you can now create a nice list like this:
\begin{blist} \item The first example is about something. \item The second remark is quite important. \end{blist}For further info, see e.g. 3.4.4 of The LaTeX Companion, Second Edition.
If you end a proof with a formula in displaymath, then the qed symbol will go to the right in a new line after the formula, which creates a big ugly white empty space in your document. And if you just put a \qedhere inside displaymath, then the qed symbol will not get pushed to the right. What to do, right? Fortunately, some good person at stackexchange gave a solution to this. I don't know how this works, or what's happening in this black box (pun intended), but the outcome is all that matters.
\[ \pushQED{\qed} \fa{\gamma\in\partial\triangle^{(1)}} {\wt_\gamma g \geq m_\gamma + 1}. \qedhere \popQED \]
\renewcommand*{\refname}{}to the preamble to get rid of the title of the bibliography, which defaults to References. Alternatively, you can put in whatever you want there. This is useful, for e.g. a list of publication, where you just want to print the list of references.
I keep a macro in the l register for compiling latex documents. This requires latexmk. For this, execute
let @l=":w\n:!if echo % | grep tex; then latexmk -pdf --synctex=1 %; fi\n"or, if you're using (t)csh,
let @l=":w\n:!if ( % =~ *.tex) latexmk %\n"This one I keep in @e to toggle spelling.
let @e=":set spell! spelllang=en\n"It is also useful to toggle autoindent as follows:
let @i=":set invautoindent\n:set autoindent?\n"
So far, I like the color scheme vividchalk. For this to work, copy the file vividchalk.vim to ~/.vim/colors/ and add the lines
syntax enable colorscheme vividchalkto your .vimrc. Don't forget to use a slick font.
To search for any nonascii character, just use
/[^\x00-\x7F]as suggested by this stackowerflow post.
The following command replaces any integer with its multiple with four.
:s/\d\+/\=submatch(0)*4/gThe expression \d\+ matches any string of digits. In the second part, the \= indicates that the string is an expression which should be interpreted. The submatch(0) gives the matched pattern, in our case a string of digits. This is then quadrupled by *4. If you need to multiply numbers inside some pattern, you can flag the number and use submatch(n), where the number is the nth flagged part. As an example, running
:s/\(\d\+\) monkey[s]*/\=submatch(1)*4 . " monkeys "/gwill turn the string
1 monkey and 4 cats and another 8 monkeysinto
4 monkeys and 4 cats and another 32 monkeys
I didn't sign up for an account at superuser.com just to upvote the very helpful answer to this post, but user138727 sure did. Put
set wildmode=list:longestinto your .vimrc, and vim will from now on do autocompletion the right way.
set expandtab set tabstop=4
The command
:%g/./.,/^$/-jmerges the lines of each paragraph into a single line. This assumes that paragraphs are separated by empty lines.
let g:Imap_FreezeImap=1Also, the following is good
let g:Tex_FoldedEnvironments="verbatim,comment,eq,gather,align,figure,table, \thebibliography,keywords,abstract,titlepage,lemma,definition,def,thm, \theorem,prop,block,rem,proof"Thanks go to Stackoverflow for educating the populus on how to continue new lines in vim scripts. Apparently, one must also include these
filetype plugin on set grepprg=grep\ -nH\ $* let g:tex_flavor='latex'
Add the following line to .vimrc to set the text width to 72, whenever editing an email (change the directory and format according to your system)
au BufRead /tmp/mutt-* set tw=72This gem, like so many others, was found on the Arch Linux wiki.
Some of these parameters should obviously be adjusted to the dimensions of your screen.
XDvi*expertMode: 0 XDvi*noInitFile: 1 XDvi*highlight: black XDvi*foreground: black XDvi*geometry: 1023x1080 XDvi*shrinkFactor: 5 XDvi*topMargin: 5cm XDvi.mainTranslations: #override \ <Key>G: goto-page(1) \n \ <Key>.: forward-page() \n \ ",": back-page() \n \ <Key>j: down(0.015) \n \ <Key>k: up(0.015) \n \ <Key>h: left(0.015) \n \ <Key>l: right(0.015) \n \ <Key>i: set-shrink-factor(+) \n \ <Key>u: set-shrink-factor(-) \n \
If you don't put in these options, an error will come your way. The special flag is important if you want text to be interpreted as LaTeX code. In this case, remember to export everything to Combined PS/LaTeX (both parts) for dvi output and Combined PDF/LaTeX (both parts) for pdf output. Better yet, use the script above to automate this.
Fig.latexfonts: true Fig.specialtext: true Fig.inches: false Fig.startgridmode: 1 Fig.startposnmode: 1 Fig.zoom: 3.0I always have to say explicitly that the color of text should be default rather than black. Otherwise the LaTeX compiler spits out an error and halts. If you find a way to do this automatically, please let me know.
For optimal desktop clock experience, use xdaliclock with the following parameters:
XDaliClock.mode: 24 XDaliClock.seconds: false XDaliClock.cycle: false XDaliClock.transparent: trueIf you're using evilwm, use the command line parameters -app xdaliclock/XDaliClock -g 444x162+a+b, where a,b is your favorite position on the desktop for a clock.
Say you have a directory /full/path/to/dir/ full of your favorite fonts. How can you use them in your favorite applications? Use the program mkfontdir to create a file fonts.dir. Then use xset to tell the system to use this directory. In short,
cd /full/path/to/dir/ mkfontdir xset +fp /full/path/to/dir/The last of these commands must be repeated every time you log in using xdm, startx or xinit or something like that. Therefore, it is good to add it to .xsession if you use xdm or startx, or to or .xinitrc if you use xinit. An excellent font for the command line is terminus.
If you don't want bash to spam you with advertisements for packages when you mistype a command, put this into your .bashrc.
command_not_found_handle() { printf "%s: command not found\n" "$1" >&2 return 127 }
Mutt is the best email client in the world. Its only downside is that its documentation—excellent as it may be—is something of a jungle. To make things simpler for anyone interested in starting using this great program, I have made my configuration files publicly available here. To get started, just follow the instructions in the README.
Don't forget to install abook. It should be available in most package systems and works pretty much out of the box.
If you're interested in using encryption, have a look at these instructions. The text may look daunting at first, but it is very much to the point and gives a practical guide to GnuPG, with emphasis on mutt. The file crypto from the above git repository has pretty much been copied directly from this manual.
To open html emails, add the following lines to your .mailcap
text/html; firefox %s &; test=test -n "$DISPLAY"; needsterminal; text/html; w3m -I %{charset} -T text/html; copiousoutput;Also, make sure to have w3m installed. This way, the hypertext will appear formatted in the pager, and you can also view it in firefox by pressing v and selecting the file. I found these lines at http://jasonwryan.com/blog/2012/05/12/mutt/ and modified them to use firefox.
*Shameless plug*—if a text based interface to email is not your cup of tea, then check out mailpile. It's an effort to make encrypted email easy and appealing, rather than having to jump through hoops like a dog. Keep in mind, though, that mailpile is still in beta stage.
Synctex is a pretty cool thing. There seem to be a lot of super complicated explanations online on how to get it to work with vim and zathura. The latex-suite even gets dragged into the whole business. Here is a simple setup which allows you to do forward search. I'll update this once I figure out how to do backwards search in a simple way.
Assume that you have a document proj.tex. First step is to compile it, producing a .pdf file and a .synctex.gz file. This is achieved by running
latexmk -pdf --synctex=1 proj.texin the directory containing the source file. Above, you can find a macro which automates this from vim. Open the .pdf document by running
zathura proj.pdfas usual. To make the viewer go to the place corresponding to line 500 in the source code, all you need to do is run
zathura proj.pdf --synctex-forward=500:1:proj.texTo wrap the whole thing up into a neat macro, keep the following in your .vimrc
let @f=":exe \"!zathura `echo % | sed s/tex$/pdf/` --synctex-forward=\" \ . line(\".\") . \":\" . col(\".\") . \":\" . \"%\"\n\n"
In order to print a unicode text file, it's not good just to feed it to the printer. Better use paps, a small program which outputs a perfectly usable Postscript document, which then can be sent to the printer.
Here is my ~/.abook/abookrc
set index_format=" {name:39} {email:39} " set show_all_emails=true set sort_field=Name
Zathura is a choice application for viewing pdf and djvu documents. What follows is my configuration file, found in ~/.config/zathura/zathurarc
set font "Terminus normal 8" set inputbar-bg black set inputbar-fg white set first-page-column 2 set guioptions "" map . navigate next map , navigate previous map C-u navigate half-up map C-d navigate half-down map C-e navigate up map C-y navigate down map i zoom in map u zoom outThe binding of . and , is inspired by the default bindings of the nice pdf viewer mupdf.
The best music player is music on cosole. The configuration file for mocp is usually ~/.moc/config. For me, this looks like
Theme = moca_theme_ed Keymap = keymap Layout1 = directory(0,0,100%,100%):playlist(0,0,100%,100%) Layout2 = directory(0,0,50%,100%):playlist(50%,0,FILL,100%)The first line selects a theme. I made small modifications to the theme moca_theme which I keep in ~/.moc/themes/moca_theme_ed and reads
background = white black frame = white black window_title = yellow black bold directory = white black selected_directory = yellow black bold playlist = white black selected_playlist = yellow black bold file = white black selected_file = yellow black bold marked_file = green black bold marked_selected_file = green black bold info = magenta black bold selected_info = yellow black bold marked_info = green black bold marked_selected_info = yellow black bold status = red black bold title = yellow black bold state = red black bold current_time = magenta black bold time_left = green black bold total_time = magenta black bold time_total_frames = magenta black bold sound_parameters = white black bold legend = white black disabled = red black bold enabled = green black bold empty_mixer_bar = green magenta filled_mixer_bar = magenta green empty_time_bar = green magenta filled_time_bar = magenta green entry = white black entry_title = magenta black bold error = red black bold message = green black bold plist_time = red black boldNote the options selected_info, marked_info and marked_selected_info which seem to be missing from many of the themes provided with the program. The second line instructs mocp to read the file ~/.moc/keymap and use the keybindings there. For me, this reads simply as as
menu_down += j menu_up += kThe last two lines switch the two default layouts, as I prefer to just use the file browser.
def_key "j" scroll_down def_key "k" scroll_up def_key "h" volume_down def_key "l" volume_up def_key "space" pause
If you're using a dark terminal, then use the following line
%colors Linuxin the file $DOT_SAGE/ipython-X.Y.Z/profile_default/startup/50-color.ipy. This tip, and more, can be found here.
It is convenient to keep the following in .gprc, if you use a dark background for your terminal:
colors = "darkbg"