To get an apostrophe in LaTeX, one can type ' (straight quote mark) or (apostrophe).

While both are compiled into an apostrophe, using breaks the syntax highlighting of curly braces in TexWorks.

Apostrophe {’} and straight quote {'}

Why does it happen and how can I prevent it?

  • Braces are already something like an environment in latex. So, I suppose if you open and "close" the quote inside your braces it will probably be highlighted. But if you finish the environment by closing the braces ... the next quote in next environment is not a quote really matching the previous but a new quote. It also would be really ugly if it was working like you would like. If a quote really starts a highlight environment with 1 "point of importance" a brace starts another with 30 "points of importance"...
    – koleygr
    Sep 8 '17 at 18:59
  • 2
    Almost certainly, that is an issue with TeXWorks, not related to LaTeX compiling. My guess is that the algorithm used by TeXWorks for matching braces dates back to the era when nobody would type a curly apostrophe directly. So, I suggest you raise the issue with TUG, the developers of TeXWorks.
    – user139954
    Sep 8 '17 at 19:22
  • 2
    Following up on @RobtAll's comment, TeXworks development takes place via GitHub, so you can report issues at github.com/TeXworks/texworks Sep 8 '17 at 20:16
  • @TorbjørnT. Thanks, I finally filed a bug there (github.com/TeXworks/texworks/issues/830).
    – Philipp
    Nov 29 '17 at 8:23

This information is a reply to my bug report, given by TexWorks developer Stefan Löffler on GitHub:

This is (somewhat) by design. The same happens, e.g., with the line Parenthesis {(} but not with, e.g., Parenthesis {()}

The reason is that any unmatched delimiter breaks the highlighting. The rationale behind this is that this should only be caused with incomplete code, in which case there is no way for the program to know what the missing code is - for all it knows that could contain more delimiters. What TeXworks considers as delimiter can be customized by editing the file ~/.TeXworks/configuration/delimiter-pairs.txt (which may be read-only by default). Your apostrophe is listed as closing delimiter, which causes your issue. Simply remove or comment the corresponding line and brace matching should work again for you as expected.

Hence, the apostrophe ’ counts as the closing element to the opening single quote mark ‘ and will not break highlighting if both are present within the curly braces. As Stefan points out, these delimiters can be customized.

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.