user13268019
user13268019

Reputation:

How to write markdown for arrow with two directions and words above and below?

I want to use Markdown to show the following picture:

I have read

Arrows with different directions

But it's about LaTeX and it did not work under Markdown.

How to use Markdown to write the above picture?

Upvotes: 0

Views: 4415

Answers (2)

Terry Ebdon
Terry Ebdon

Reputation: 527

You can accomplish this in Doxygen.

# Markdown for arrow with 2 directions & labels above & below

## Intro

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 

## Important diagram

Uses Graphviz Dot to create the diagram.

\dot
digraph G {
  rankdir="LR";
  node[shape=none, fontsize=56]

  1 -> 2 [label="a"]
  2 -> 1 [label="b"]

  3 -> 4 [label="d"]
  4 -> 3 [label="e"]
}
\enddot

## Summary

Aenean commodo ligula eget dolor. Aenean massa. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur.

Resulting HTML

The generated HTML will display similar to this:


Web page fragment generated from markdown


Label position

By default the labels are above the lines. To move the labels add anlp attribute to the edge.

2 -> 1 [label="b", lp=12]

Where lp means label position and 12 is the centre position of the label

Attributes are described in the Graphviz Node, Edge and Graph Attributes page.

Upvotes: 1

Chris
Chris

Reputation: 136984

Markdown itself doesn't do anything like this. Its scope is quite limited:

The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

It's true that extensions and flavours of Markdown have subsequently been released that add features to the original format, e.g. tables and strikethrough.

But to show something like you want you'll need to use something like LaTeX or MathML. It simply isn't supported by Markdown or HTML natively. All Markdown extensions that I've seen supporting this kind of notation rely on some LaTeX implementation to do the rendering.

Depending on the Markdown implementation you're using you might already be able to use LaTeX. For example, Jupyter enables LaTeX via MathJax using $ and $$ delimiters. If your implementation doesn't support LaTeX out of the box you may be able to add it, e.g. using the aforementioned MathJax JavaScript library.

Upvotes: 1

Related Questions