0

I would like to show a matrix (mathematical entity) in rust doc comments. I tried using this:

/**
For example, given the projection matrix:

        1   0   0   0
        
        1   0   0   0

        1   0   0   0

        1   0   0   0
*/

While it looks acceptable in the code, the generated comments seem to remove the extra spaces between each matrix element. It looks something like this:

enter image description here

What would be the best way to format this matrix correctly? Or is this the best I'm going to get?

My IDE is VS Code, with extension rust-analyser installed only.

UPDATE:

It does not seem to be an IDE issue, as the generated docs using cargo doc --open shows similarly un-formatted matrix:

enter image description here

l3utterfly
  • 2,106
  • 4
  • 32
  • 58
  • This seems to be a problem with the IDE you are using. If you look at the output generated by rustdoc (`cargo doc --open` will generate documentation and open it in your browser), it looks good (because of the indentation, the matrix is formatted as code). Therefore, please add information about your IDE setup. – Elias Holzmann Jul 22 '21 at 11:23
  • Oh, didn't know it was due to the IDE.. my IDE is VS Code, which should be pretty common one I'd imagine. Updated question – l3utterfly Jul 22 '21 at 11:24
  • 1
    Trying adding three backticks each on the lines before and after the matrix. Then indent the whole thing (including the backticks) by 4 spaces, since it seems to be inside a list. – L. F. Jul 22 '21 at 13:23
  • @L.F. Looks much better after doing this – l3utterfly Jul 22 '21 at 13:27

1 Answers1

0

If you want to have a matrix generated from LaTeX, you can use the macro I've written: https://github.com/JohnScience/include_display_mode_tex

Dmitrii Demenev
  • 735
  • 1
  • 5
  • 13