[texworks] Wrapping a text in math mode

Uwe Ziegenhagen ziegenhagen at gmail.com
Thu Sep 26 01:21:47 CEST 2013


You could also use a shortcut expander (autohotkey on Windows, Textexpander
on Mac OS or Autokey on Linux). Here's an example for Autohotkey, one of my
most favorite tools:

:*:\(::\(\){LEFT 2}


as soon as "\(" is pressed "\)" is added and the cursor is put between
behind the "(".


Uwe

PS: Autohotkey makes TeXing much faster in general, here are a few
shortcuts from my AHK file. "i#" is the shortcut, behind the :: is the
expanded text.


:*:i#::\item{Space}
:*:di#::\item[]{LEFT}
:*:it#::\textit{{}{}}{LEFT}
:*:item#::\begin{{}itemize{}}`r\item `r\item `r\item `r\end{{}itemize{}}{UP
3}
:*:citem#::\begin{{}compactitem{}}`r\item `r\item `r\item
`r\end{{}compactitem{}}{UP 3}

:*:s#::\section{{}{}}{LEFT}
:*:sc#::\textsc{{}{}}{LEFT}
:*:ss#::\subsection{{}{}}{LEFT}
:*:sss#::\subsubsection{{}{}}{LEFT}
:*:std#::\usepackage[utf8]{{}inputenc{}}`r\usepackage[T1]{{}fontenc{}}`r\usepackage{{}booktabs{}}`r\usepackage{{}babel{}}`r\usepackage{{}graphicx{}}`r\usepackage{{}csquotes{}}`r\usepackage{{}paralist{}}`r\usepackage{{}xcolor{}}












2013/9/25 Alain Delmotte <esperanto at swing.be>

> Hi!
>
>
> Le 25/09/2013 09:43, Pavel Dvořák a écrit :
>
>> H
>> ​i all!
>>
>> Very often when I write a mathematical formula ​within a
>> text paragraph, I often forget to enclose it in math
>> environment \(...\). What I have to do then is to cut this
>> expression with CTRL+X, introduce math environment
>> \(...\)
>> ​ and paste it back into it with CTRL+V.
>>
>> Is there a way to wrap this ​expression directly in the math
>> environment
>> \(...\)
>> ​? For example, if I write an expression p_{12}+\log(x)
>> instead of
>> \(
>>>> p_{12}+\log(x)
>> \)
>> ​, I would like just to select the first expression with my
>> mouse, hit, for example, CTRL+Y and transform it to the
>> second expression in math mode. ​
>>
>
> You can write a script following the example given below, put the script
> in the script sub-folder of the TeXworks resources folder (you didn't tell
> us which OS you are using - see the manual).
> It will appear in the scripts menu of TeXworks and you can follow the
> behaviour you asked for.
>
> Regards,
>
> Alain
>
>
> ====== my script "b-verb.lua"
> --[[TeXworksScript
> Title: b: verbatim \&verb
> Shortcut: Alt+V
> Description: Encloses the current selection in \verb||
> Author: Alain Delmotte from Stefan Löffler & Jonathan Kew
> Version: 0.1
> Date: 2011-11-01
> Script-Type: standalone
> Context: TeXDocument
> ]]
>
> txt = TW.target.selection
> if (txt == nil) then txt = "" end
> TW.target.insertText("\\verb|" .. txt .. "|")
> TW.target.selectRange(TW.**target.selectionStart - string.len(txt) - 1,
> string.len(txt))
> ========
> the keyboard short-cut is Alt+V
> The & on the second line (Title) creates an accelerator in the scripts
> menu (the v letter is underlined and pressing v when the menu is open
> execute the script)
> in the Title "b: verbatim", the b: is for sorting the scripts in the menu,
> not necessary but useful (for me!!)
> The action is in the 14th line (the third of the program itself, here put
> the selection into the inline verbatim: \verb|selection|
>
>
>
>


-- 
Uwe Ziegenhagen
<http://www.uweziegenhagen.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texworks/attachments/20130925/4befcb28/attachment.html>


More information about the texworks mailing list