[Tex/LaTex] How to insert inline `code` in Lyx

codelyx

I want to add an inline text formatted as code in Lyx. For example:

"The gradient is calculated via math::gradient(v)"

I am aware of the Insert List command, but it is not what I'm looking for since the code listing is not inserted inline. I have searched everywhere, but I can't find the way to do it.

Thanks in advance.

Best Answer

You can insert an inline program listing in LyX as follows:

  1. Insert > Program Listing
  2. With the cursor inside the newly created listings box, go to Edit > Listings Settings (or right click inside the box and choose "Settings").
  3. In the settings dialog, check the box "Inline listing".

Starting with LyX 2.3.0, you can optionally choose to (globally) use the minted package for listings, by going to Document > Settings > Listings and selecting "Minted" in the combo box.