I was wondering how do one find/use snippet manager for LaTeX code snippets in TeXnicCenter? I want to be able to define keyboard shortcuts such as for e.g.,

keystrokes: shift + $+$\[ <cursor> \] and shift + $\( <cursor> \)

Is this possible to implement? I am sure I will find other useful nitbit shortcut commands later on that will be useful for faster typing.

  • Someone may consider adding or changing the tag to something more descriptive if possible. – night owl Oct 10 '11 at 8:20
  • 1
    I don't use TeXnicCenter, so I can't really help you there. You could use something like Auto-Hotkey to set that up to work regardless of what editor you are using though. – Roelof Spijker Oct 10 '11 at 9:17
  • I think there is no real hotkey manager in texniccenter (at least not when I used it a while ago). The auto-completion functions are somewhere in the texniccenter folder in xml files. you might be able to add a function that lets you auto-complete the environments you want with Ctrl+Space. An externam hotkey tool might be easier... – Martin H Oct 10 '11 at 9:24
  • 1
    With regards to xml files, see this question: tex.stackexchange.com/questions/17240/… – Torbjørn T. Oct 13 '11 at 13:28

TeXnicCenter allows you to add shortcuts to menu items only. Moreover, these shortcuts are required to be a "single-combined keypress event". Let me explain:

In your preference, the choice of Shift+$ is contained in Shift+$+$. As such, you can assign the former to execute the menu sequence Insert -> Formulas -> Formula. This will insert $<cursor>$. Repeating this (by keeping Shift pressed and just pressing $ again), TeXnicCenter will insert a similar formula, which produces $$<cursor>$$.

This is how you do it in TeXnicCenter:

  • Tools -> Customize -> Keyboard
  • Under Category, choose Insert
  • Under Commands, choose Embedded Formula
  • In Press New Shortcut Key, while holding Shift, press $
  • Press the Assign button

Keyboard customization in TeXnicCenter

Some caveats or considerations with regards to this technique: Whenever you use Shift+$ you will receive $<cursor>$, even if you only want to type \$ (say). Depending on your usage, this may be undesirable. Also, the use of $$...$$ in LaTeX typesetting for displaymath has been succeeded by \[...\] (see the l2tabu documentation). You can set a separate keyboard shortcut for this (the menu item Insert -> Formula -> Formula produces

To obtain exactly your preference (similar keystrokes to yield a choice between \(<cursor>\) and \[<cursor>\]) is not possible. You will have to produce completely separate keystroke combinations to obtain these different replacements. Note, however, that you can use Ctrl and Alt as well. So, for example, you could use:

  • Ctrl+Alt+4 for $<cursor>$
  • Ctrl+Alt+Shift+$ for \[<cursor>\]

With the above description, it should be straight-forward to do this.

  • +1... Werner: Thank You you so much for an elaborate response. This was very helpful. I like to actually be able to to understand and learn something from reading a response and yours did just that and summed it up in a less rigorous LaTeX explanation. – night owl Oct 11 '11 at 12:35
  • So when using the last option: Ctrl+Alt+4 for \(<cursor>\) and the: Ctrl+Alt+Shift+4 for \[<cursor>\]... I do not get the result as told. I just get $<cursor>$. Can I not get \(<cursor>\) and \[<cursor>\]? – night owl Oct 20 '11 at 7:39
  • @nightowl: I mistakenly put \(<cursor>\) in my final summary, as opposed an Embedded formula resembling $<cursor>$. I've corrected this in my updated answer. Not sure how fix this to print $\(<cursor>\)$. However, they are exactly the same in the typeset output. – Werner Oct 20 '11 at 8:04
  • Correct, I know they do the same job, but I read that $...$ and $$...$$ are both succeeded by \(...\) and \[...\] respectively. I do not know exactly why for $...$ but I did hear that it was because of spacing issues related to using $$...$$. So is there a way to created a keyboard shortcut to produce \[ <cursor> \]? – night owl Oct 20 '11 at 8:09
  • Read the l2tabu documentation for more information on why \[...\] as opposed to $$...$$. Also, see Why is [ … ] preferable to $$? My example above shows how to set Embedded Formula, which translates to $<cursor>$. You need to do the same for Formula if you want \[<cursor>\]. – Werner Oct 20 '11 at 8:22

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.