1

Suppose I have the following code snippet in my *.tex document (src ;-) ):

Dolorem ipsum color sit amet.

I'd love to be able to select part of that text (e.g. color), do something quick and convenient (Macro? Keyboard shortcut? Key binding? Other?) to add something to make the typeset text be colored. In other words, I want a shortcut to turn the above line into the following line:

Dolorem ipsum \textcolor{red}{color} sit amet.

Is there a way within TeXShop to quickly change the (typeset) color of selected text without inserting the code manually? I want to do this frequently, so I want it to be as quick as possible.

This is very similar to Does TeXShop for Mac have key bindings?, except I want to make the text a particular color instead of making it bold (which has many more possible solutions).

3

You can create a “red text” Keyboard Binding in TeXShop.

To do so, navigate to the “Edit Key Bingings File…” menu option:

screenshot of key bindings menu

Next, add the following line (note that the ̉ in the Input field is OPT+SHIFT+Z):

screenshot of Key Bindings Editor window

Finally, click the “+” button to add it, and click “Save” to save changes and close the dialogue.

Now, whenever I select some text and type OPT+SHIFT+Z, the selected text gets surrounded by \textcolor{red}{ and }, which renders that text red.

Notes

  • Keyboard Bindings must be enabled for this to work. To check this, ensure that there's a check mark next to the "Toggle On/Off" menu option in the first image above.
  • You could presumably use any "input" key binding. I chose OPT+SHIFT+Z because it wasn't taken, is uncommon enough to not cause a mistake, and because these keys could be easily pressed on my keyboard with one hand.
  • It goes without saying that you could change the red to a color of your choice.

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.