Search code examples
slideshowmarp

How can I change the font of code block in Marp?


I want to know if it's possible to change the font of the code block in marp. If it is possible I'd like to know how to do this. This is my code block:

char *strcpy(char *dest, const char *src)
{
   char *p = dest;
   while(*p++ = *src++);
   return dest;
}

I tried adding this since I saw someone using this to alter the code block font size so I assumed that doing the same with font-family would work. This is the code:

<style scoped>
pre {
   font-family: Courier New;
}
</style>

but it didn't help.


Solution

  • What i found to work in my document is using the code class to format code:

    <style scoped>
    code {
       font-family:  "Times New Roman", Times, serif;
    }
    </style>
    

    Addtionally, you might need to put the name in quotation marks.