TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to use AutoHotKey to facilitate LaTeX document authoring? In which ways? Is there any off the shelf AutoHotKey script for this purpose?

share|improve this question
It doesn't really matter from which language you call (la|con)?tex(t)? (given that the language supports executing system commands). Unless you mean implementing TeX in AutoHotKey. That'd be a feat. – morbusg Jun 28 '12 at 14:38
@morbusg I want to know experiment of TeX.SE users in using AutoHotKey if any. – PHPst Jun 28 '12 at 16:17
up vote 3 down vote accepted

In general, I'm very inaccurate when typing things like "\", "{", "$" etc. It's especially cumbersome to navigate text with the Left, Right, Up and Down keys and you do all of these things constantly when typing tex.

I haven't spent much time learning how to write scripts with AHK, but I did write a few things to make a few shortcuts and to save the amount of which my wrists have to bend while typing tex.

For example, these I wrote for my preference.

^space:: Send {{}{}}{Left}
CapsLock:: Send {$}{$}{Left}
^9:: Send {(}{)}{Left}
^l:: Send {Right}
^j:: Send {Left}
^i:: Send {Up}
^m:: Send {Down}
^k:: Send {Down}
+^l:: Send +{Right}
+^j:: Send +{Left}
+^i:: Send +{Up}
+^m:: Send +{Down}
+^k:: Send +{Down}
^f:: Send {^}
^p:: Send \pause{Enter}{Enter}
^h:: Send \
^n:: Send \{{}\{}}{Left}{Left}
^;:: Send {End}
^Backspace:: Send {Delete}
^=:: Send {&}={&}

I came here because I too was wondering if someone with professional knowledge of AHK had written something useful for writing tex.

share|improve this answer

You can use AutoHotKeys to define a bunch of keyboard shortcuts for the most often used LaTeX commands:

\begin{<input your environment name>}
\end{<AutoHotKeys automatically closes it with the same environment name>}

\item <cursor is put here>




But if you're willing to invest time in learning a tool to ease LaTeX document authoring, I suggest emacs and the good AUCTeX extension. It has many well-thought keyboard shortcuts, syntax highlighting (including bold for \section), jump to the point of compilation error, table of content navigation, etc. http://www.gnu.org/software/auctex/features.html

Works under Linux, Windows and Mac.

share|improve this answer
How do I get Autohotkey to close the current environment automatically. So far I use b# to expand to \begin{} but I am looking for a more sophisticated solution. – Uwe Ziegenhagen Sep 25 '13 at 23:25
This comment should be converted to a full question, about autoHotKeys (and this not on TeX.SE). – jrouquie Sep 26 '13 at 8:49

By accident I found this question and also by accident I found an answer a long time ago:


The guy there, Mr. Ziegenhagen, blogs some useful scripts in order to make the LaTeX life easier. Some examples:

InputBox, UserEnv, Environment, Please enter an environment!, , 240, 120
If ErrorLevel
if( RegExMatch(UserEnv, "(.*?)(\d+)$", splitted) ) {
    Send \begin{{}%splitted1%{}}{Enter}
        Loop %splitted2% {
            Send \item {Enter}
    Send \end{{}%splitted1%{}}{Up}
    count2 := splitted2 - 1 
    Loop %count2% {
        Send {Up}
    Send \begin{{}%UserEnv%{}}{Enter 2}\end{{}%UserEnv%{}}{Up}

If you press Alt+e and enter e. g. itemize3 then the script will insert


I think that's great! Here are some more examples:




:*:desc#::\begin{{}description{}}`r\item[]`r\item[]`r\item[]`r\end{{}description{}}{UP 3}{LEFT}
:*:enum#::\begin{{}enumerate{}}`r\item `r\item `r\item `r\end{{}enumerate{}}{UP 3}
:*:item#::\begin{{}itemize{}}`r\item `r\item `r\item `r\end{{}itemize{}}{UP 3}

See also this question. Here are more examples from Mr. Ziegenhagen's blog:


share|improve this answer

Short question, short answer:

  1. Yes.
  2. AFAIK: No.
share|improve this answer
It seems you missed the second of his three questions. As it stands now, I don't think this qualifies as an answer, but should rather be put as a comment. – canaaerus Sep 13 '12 at 16:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.