6

What is the equivalent of the LaTeX-code \textit{} in ConTeX? It sets the text in the brackets italic. There is \it but I am searching for something like \startit...\stopit.

11

You can use \italic{some text}. However it's better to not directly apply formatting to your text, use a logical markup instead.

\definehighlight
  [emphasis]
  [style=italic]

\emphasis{some text}
{\emphasis some text}

You should have a look at the user manual.

  • Thank you. Why this way is better? – Mustafa Oct 16 '12 at 13:32
  • 2
    Because it enables you to separate content and logical markup and the style and visual representation. Italic means italic, always. Emphasis can be represented as italic, bold, red, underlined. If you code you documents with logic markup you can apply a style file (sitting in an environment file) which results in a totally different representation of the content. Hard coded styles do not allow that. This is particularly useful when you use the XML export backend. – Marco Oct 16 '12 at 13:36
6

Define an environment as usual (\definestartstop) and set the style key:

%% environment:
\definestartstop[important][style=italic]
%% monadic macro:
\definehighlight[dontmiss] [style=italic]

\starttext
  foo
  \startimportant bar \stopimportant
  baz
  \dontmiss{xyzzy}
\stoptext

Btw. it is recommended to name you macros semantically, e.g. \important or \keyword instead of \italic. This way you can adapt the style later by changing one parameter in the setup without having to mess with the content.

illustration of emphases

EDIT: In ConTeXt, the generic emphasis command is \emph. With vanilla settings it defaults to slanted like the TeXbook. You can override the default via \setupbodyfontenvironment[default][em=italic]. Now \emph{foo} will be set in italics as well.

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.