[OS X TeX] TexShop: macro to insert text, preserve indentation

Nicolae Garleanu garleanu at haas.berkeley.edu
Mon Jun 4 09:29:58 EDT 2012


I don't think this is worth much of anyone's time, so let me rephrase succinctly what I was looking for: a macro that replicates exactly the behavior of my typing in hand <Enter> followed by "\item". For instance, if I first type


with the indentation of "\item" added by hand, and then type <Enter>, then the cursor is not placed at the beginning of the line, but directly under "\" in "\item". My macro, on the other hand, puts everything at the beginning of the line. I think that the `right' macro, if it exists, would mimic the behavior of TexShop when I type directly — how does TexShop end up preserving the indentation?

I think that Tidy would achieve a certain look close to, if not identical to, what I wish for, but I would prefer the formatting to happen in real time and not to have to go through additional motions such as selecting text, etc.


From: Herbert Schulz <herbs at wideopenwest.com<mailto:herbs at wideopenwest.com>>
Reply-To: TeX on Mac OS X Mailing List <macosx-tex at email.esm.psu.edu<mailto:macosx-tex at email.esm.psu.edu>>
To: TeX on Mac OS X Mailing List <macosx-tex at email.esm.psu.edu<mailto:macosx-tex at email.esm.psu.edu>>
Subject: Re: [OS X TeX] TexShop: macro to insert text, preserve indentation

On Jun 3, 2012, at 8:32 PM, Nicolae Garleanu wrote:

> Hi,
> I wanted to write a macro that inserts "\item" on the line below — specifically, that behaves exactly as when I type <Enter>, the type the text. When I do that, in particular, "\item" is indented just like the previous instance of "\item". For my macro, the only thing I could think of was to have an empty line followed by my text ("\item"). As some of you might guess, that does what I want save for inserting the text at the very beginning of the second line, rather than preserving the indentation as when I type it directly in the source code. (Command completion, for instance, places the first "\item" indented, all the others follow.)
> How could I get the desired behavior? I should also say clearly that the more explicit the answer, the better. (I have virtually no experience with Applescript, although I expect to be able to modify reasonably closely related code.)
> Thank you.
> Nicolae


Don't have a direct answer for you but have you tried the LaTeX Tidy Service? YOu can get it at <http://www.inf.unibz.it/~franconi/sw/Tidy.service.zip>. Once in place you can make a selection of a region go to your Apple->Services menu and select the Tidy service and that region gets re-formatted. Unfortunately I don't know how to make it format in different ways and it tends to put the text starting on the same line as the \item and indents all the \item commands.

Can you show how you'd like things to look?

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://email.esm.psu.edu/mac-tex/
List Archive: http://tug.org/pipermail/macostex-archives/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://email.esm.psu.edu/pipermail/macosx-tex/attachments/20120604/82a8e613/attachment.html>

More information about the MacOSX-TeX mailing list