2

I have an active string that when I type \[ it enters

\[

*

\]

*

I obviously have problems when I want to type

\\[8pt]

I was wondering if there is a way that I can change the active string to take care of this problem.

4
  • You can leave a space: \\ [8pt] is good as well.
    – egreg
    Apr 5 '14 at 8:27
  • @egreg -- if one is using amsmath, \\ [8pt] used in a multi-line display will just happily print out [8pt] at the beginning of the next line. there were so many complaints about problems with expressions that began with a bracket that mike worked very hard to disable the "check after space" so that people could leave a space rather than having to wrap braces around the opening bracket. Apr 5 '14 at 20:43
  • @barbarabeeton Which was an error, in my opinion. Or possibly it was an error to allow an optional argument for \\.
    – egreg
    Apr 5 '14 at 20:46
  • @egreg -- if it had always been required to have no space before the optional dimension, that could have been explained as a consistent rule. but the way it is now, you're correct -- it's very confusing. but we really did get a lot of complaints. this is reasonably similar to the knuth requirement for \relax after \cr in alignments before doing certain things. but mike isn't around any more to defend his decisions. (maybe frank remembers.) Apr 5 '14 at 21:29
4

I think another solution would consist in using this macro (which I name d-math.edt in the explanations that follow):

BeginGroup;
InsLine;
GoToBeginningOfLine;
Indent;
Ins("\[ \]%");
PreviousBullet;
EndGroup;

The macro shortcut is defined through this addition to the Shortcuts menu in `MainMenu.ini:

  ITEM="\[ \]"
    MACRO="Exe('%b\Local\macros\d-math.edt')"
    SHORTCUT="32954::Alt+$"
    REQ_DOCUMENT=1 

Of course, the choice of the shortcut is based on what's most convenient and meaningful for your keyboard layout (mine is good for an azerty layout). As you can see I've put the macro file in %b\Local\macros, but you can adapt that according to your habits – somewhere in %b, though.

Added: if you want to use the active string way, you just have to add to your caracterisation of \[ as an active string in ActiveStrings.ini:

START_FILTER="~\"
1
  • @per: I've updated my answer so as to use the active string way.
    – Bernard
    Apr 5 '14 at 19:42
2

This is how I solved this problem. This code works in WinEdt9.

Go to the menu item Options -> Options Interface

There you will find a long list of items. Down this list is

Delimeters, Active strings, Abbreviations

Open this item.

Click on Active Strings. The long file with active strings will appear in the right pane. This is an editable file in which you can add your own active strings.

Find the following string

STRING="\["
   ENABLED=1
   MODE_FILTER="TeX|DTX;INS;STY;AUX"
   MACRO="[Ins('\]');CharLeft(2);]"
   DBL_CLICK_ENABLED=1
   DBL_CLICK_MODE_FILTER="TeX"
   DBL_CLICK_MACRO="[MatchDelimiter(1,1,1);]"

Right before the string copied above add the following new string. You can just copy and paste the code below.

STRING="\\["
   ENABLED=1
   MODE_FILTER="TeX|DTX;INS;STY;AUX"
   MACRO="[Ins(']');CharLeft(1);]"

The next step is essential. After any modifications of ActiveStrings.ini , instead of saving the file, you have to click "Load Current Script" which is the left-most icon immediately below the title "Options Interface"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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