Theme
I’m sharing some more info about how the site was created and how i’ve modified from the original theme.
This site is powered by jekyll and hosted on GitHub Pages. The theme is no-style-please. For a run through of what some typical markdown features look like in this theme, look here.
Modifications
I have added some personal options that I’ll run through below:
Images
(Images are naturally centered in this theme, check the stylesheet _sass/no-style-please.scss
)Native Markdown has the following command to display an image:
![alt text](image.jph)
resulting in:
To add a caption, center the image and caption, and include an optional URL: create image.html
in the _inludes
directory with the following content:
<!-- _includes/image.html -->
<div class="image-wrapper" >
{% if include.url %}
<a href="{{ include.url }}" title="{{ include.title }}" target="_blank">
{% endif %}
<img src="{{ site.url }}/{{ include.img }}" alt="{{ include.title }}"/>
{% if include.url %}
</a>
{% endif %}
{% if include.caption %}
<p class="image-caption">{{ include.caption }}</p>
{% endif %}
</div>
Now we can use jekyll layout syntaxing to input an image with the following options:
- img: path to the image
- title: alt text
- url: (optional) url the image will point to
- caption: (optional) caption that will be displayed under the image
In a css file add the following:
.image-wrapper {
text-align: center;
}
.image-wrapper .image-caption {
color: #919191;
margin-top: 1.5;
}
Now to insert an image issue the following:
{% include image.html
img="assets/images/messi5.jpg"
title="Messi"
caption="This is Messi5" %}
Writing Math
MathJax is a JavaScript engine for mathematics that works in all browsers. It allows for an extension to vanilla markdown’s interpretation of LaTeX style mathematics syntax. I primarily just wanted the capability to have numbered equations, but MathJax comes with more capabilities.
To enable MathJax, add the following to a file in _includes/head.html
:
{% if page.usemathjax %}
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>
<script type="text/javascript" async src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{% endif %}
Then enable MathJax in the header section of your markdown document with jekyll syntaxing:
usemathjax: true
.
Then write an equation $$ \begin{equation} a + b = c \label{eq:one} \end{equation} $$
with:
\$$
\begin{equation}
a + b = c \label{eq:one}
\end{equation}
$$
Adding the label
tag will create an anchor, which can be used with \eqref{eq:one}
- Equation \eqref{eq:one}.