Embed without Any Link

I have a note with many MathJaX macros called MathJaXMacros.md:

$$
\DeclareMathOperator{\sign}{sign}
\DeclareMathOperator{\prox}{prox}
\DeclareMathOperator{\rank}{rank}

\newcommand{\MyParen}[1]{\left( #1 \right)}
\newcommand{\MyBrack}[1]{\left\lbrack #1 \right\rbrack}
\newcommand{\MyBrace}[1]{\left\lbrace #1 \right\rbrace}
\newcommand{\MyMat}[1]{\begin{bmatrix} #1 \end{bmatrix}}
\newcommand{\MyNorm}[2]{{\left\| #1 \right\|}_{#2}}
\newcommand{\MyAbs}[1]{\left| #1 \right|}
\newcommand{\MyNormTwo}[1]{\MyNorm{#1}{2}}
\newcommand{\MyCeil}[1]{\lceil #1 \rceil}
\newcommand{\MyInProd}[2]{\langle #1, #2 \rangle}
\newcommand{\MyUndBrace}[2]{\underset{#2}{\underbrace{#1}}}
\newcommand{\RR}[1]{\mathds{R}^{#1}}
\newcommand{\BS}[1]{\boldsymbol{#1}}
\newcommand{\MyClr}[2]{{\color{#1}{#2}}}
$$

I want to embed is in other notes I have which use MathJaX.

I am adding to them something like ![[MathJaXMacros#^c8c481]].
It works functional wise.
Yet, the embedding note will have something like:

Is there a way to prevent it?
Namely, embed the note without any link shown on the embedding note.
Something like hidden embedding for such cases.

Yup, it’s possible by using a CSS snippet, as follows:

/* hide the right-side link icon */
.markdown-embed-link >.svg-icon.lucide-link {
  display: none;
}

/* hide the left-side border */
.markdown-embed {
  border-left: none;
}
1 Like

Not answering the original question, but I think this is what you’re looking for

With this plugin, you will not need to embed MathJaxMacros.md in every note you create. Plus, it doesn’t affect how your notes look.

1 Like

OK, Can I make it specific to some links and not global?

Yup, as follows:

/* hide EMBEDDED link markers */
.markdown-embed[src*="Untitled"] .markdown-embed-link svg {
  display: none;
}

/* hide EMBEDDED border */
.markdown-embed[src*="Untitled"] {
  border-left: none;
}

where you replace Untitled with your desired part of the note title (or even the whole note title if you want) that you want this to apply to.

2 Likes

I see.
So if I want to embed from a note called MathJaXMacros I should replace "Untitled" with "MathJaXMacros". Right?

Where do I put this CSS snippet?

1 Like

That is correct.

Have a read on the Obsidian documentation here:

2 Likes

I created a .css file and Obsidian loads it as a CSS snippet.
It works!

It still creates excessive top and bottom margins, but no link icon or left border.

I thought about something else, can I, using the CSS, embed the MathJaX SVG in this container?

https://www.mathjax.org/badge/mj-logo.svg

1 Like

OK, so I’ve refactored the whole CSS snippet to remove leftside spacing as well, and to insert your custom SVG instead of the default link on the right side (any top/bottom margins you see are either from your theme or plugins, because on my end I don’t have any margins). Result:

Screenshot-25_11_2023-11.26.42

The new CSS snippet:

.markdown-embed[src*="MathJaXMacros"] {
  /* remove left border & spacing */
  border-left: none;
  padding: 0;
  margin: 0;
  
  & .markdown-embed-link {
    /* make sure custom SVG is fully opaque */
    opacity: 1;

    /* hide default link icon */
    & svg {
      display: none;
    }

    /* insert custom SVG instead */
    &::after {
      content: url(https://www.mathjax.org/badge/mj-logo.svg);
      display: block;
      width: 100px;
    }
  }
}
2 Likes

Alother option is using alt / attribute text so the CSS isn’t bound to the note name.

.internal-embed[alt*="cleanish"],
.internal-embed[alt*="cleanish"] svg {
    border-left: none;
    display: none;
}

And you’d write the link as ![[MathJaXMacros#^c8c481|cleanish]]

Either way, you’ll need to manually change something (in the CSS for the file name if you rename it, or in the attribute text) if you want the no left border and no link icon for only certain embeds.

If you want a no left border and no icon for all embeds, that’s easy. :hatching_chick:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.