Creating LaTeX environments with Autohotkey the easy way
Here’s a neat little script (bound to Alt-e
) which requests an environment name from the user. If the entered string has e.g. the form "itemize3"
it creates
\begin{itemize} \item \item \item end{itemize}
and puts the cursor directly after the first \item.
If the entered string includes no number at the end (e.g. „itemize“), just the environment is created.
!e:: InputBox, UserEnv, Environment, Please enter an environment!, , 240, 120 If ErrorLevel return Else 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} } } Else Send \begin{{}%UserEnv%{}}{Enter 2}\end{{}%UserEnv%{}}{Up} return
Thx to MCL for providing help with the regexp!