• Stars
    star
    324
  • Rank 129,708 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make posters from Markdown files.

MkPosters

Create posters using Markdown. Supports icons, admonitions, and LaTeX mathematics.

At the moment it is restricted to the specific layout of two-columns-with-banner-at-the-top, as that's what I tend to use. (Pull requests are welcome if you want to make this tool more general.) The poster can be either portrait or landscape.

The library operates by parsing your Markdown into HTML, styling it with CSS, and then opening a webpage that you can export to PDF.

Example

Example poster

The "source code" for this example is here.

Assumptions

Assumes you have:

  • Linux (WSL is fine) or macOS
  • Firefox
  • Python

Compatibility with other operating systems is probably possible by switching out the version of Dart Sass being used internally.
Compatibility with other browsers is unlikely.

You'll need to be relatively familiar with HTML and (S)CSS to make best use of MkPosters.

Installation

pip install mkposters

Usage instructions

  1. Create the appropriate directory structure
foo/
    poster.md
    style.{css,scss} (optional)
    ...any other assets e.g. images...
  1. Lay out your poster

poster.md should be formatted in three sections, with a literal "--split--" between each section.

...whatever you want in the banner at the top...

--split--

...whatever you want in the left column...

--split--

...whatever you want in the right column...
  1. Build poster

Run from the directory containing foo:

python -m mkposters foo

The first time you do this, MkPosters will attempt to detect your system architecture and install the appropriate version of dart-sass. This was tested working on both an Apple M1 and an Ubuntu x86_64 machine.

This will also automatically watch the foo directory for any updates, and rebuild if necessary.

  1. View poster

Now open Firefox (not Chrome etc.) and navigate to localhost:8000.

What you see will be based on the size of your current browser window and may differ from the PDF version. So next hit Control-P and select "Save to PDF". What you see in the print preview is what you'll actually end up with!

Make all your edits until you're happy with the result. Now let's save the result to PDF.

  1. Save to PDF

Saving to PDF can be quite finickity, and in general depends on choice of browser etc. (For what it's worth the following is tested using Firefox on Windows 10 with mkposters running on Ubuntu 20.04 on WSL2.)

In the print dialog window we opened above:

  • Destination: "Save to PDF". Do not use "Microsoft Print to PDF".
  • Orientation: (portrait or landscape, as desired)
  • Pages: Custom: 1
  • Paper size: (whatever is desired; current styling works best on paper roughly A4 sized)
  • Margins: None
  • Options: uncheck "Print headers and footers"

Once again, make sure you're using Firefox. Using other browsers (e.g. Chrome) or other PDF exporters (e.g. WeasyPrint) can introduce a variety of issues, such as saving text as images (which are unselectable in the PDF, and appear slightly pixelated), missing parts of the styling, or having faded colours (looking at you, Chrome).

Functionality

MkPosters comes with a few extra pieces of functionality built in.

Icons

Recalling that Markdown can embed HTML, then icons can be embedded via e.g.

<img style="height: 20pt; width: 20pt" src="icons/fontawesome/brands/github.svg">

where the list of available icons is here.

Mathematics

You can use LaTeX-formatted mathematics. This is done via

\\(inline math\\)
\\[display math\\]

Note the double backslash.

Admonitions

Admonitions can be added using the syntax

!!! admonition_type "Your title here"

    Your text here

where admonition_type is any of these types, e.g. info, tip, etc.

Custom (S)CSS styling

If you want to style your poster in a custom way, then you can include a style.css or style.scss file in your poster directory.

HTML

The Markdown format allows you use arbitrary HTML inside of it.

  • The banner section often contains information (titles, authors, logos, URLs etc.) laid out in complicated ways. Directly writing HTML with embedded style attributes is simplest here. See the start of this example.
  • HTML can be (ab)used to modify spacing like so. (Analogous to those little \vspaces you definitely never use in LaTeX documents.) In this example we move the content up by 10 points.
<div style="margin-top: -10pt;">
...your content here...
</div>

Future plans?

It'd be nice to support:

  • Other poster layouts, e.g. multiple columns;
  • Optionally automatically generating the PDF. (Practically speaking probably by automating the Firefox interaction through Selenium.)
  • Reducing package size by not including all of the mkposters/third_party/icons directory by default?

Pull requests welcome! See CONTRIBUTING.md.

Similar tools

These all support some kind of conversion Markdown -> something.

More Repositories

1

equinox

Elegant easy-to-use neural networks + scientific computing in JAX. https://docs.kidger.site/equinox/
Python
2,029
star
2

torchtyping

Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.
Python
1,380
star
3

diffrax

Numerical differential equation solvers in JAX. Autodifferentiable and GPU-capable. https://docs.kidger.site/diffrax/
Python
1,369
star
4

jaxtyping

Type annotations and runtime checking for shape and dtype of JAX/NumPy/PyTorch/etc. arrays. https://docs.kidger.site/jaxtyping/
Python
1,117
star
5

NeuralCDE

Code for "Neural Controlled Differential Equations for Irregular Time Series" (Neurips 2020 Spotlight)
Python
610
star
6

torchcde

Differentiable controlled differential equation solvers for PyTorch with GPU support and memory-efficient adjoint backpropagation.
Python
411
star
7

lineax

Linear solvers in JAX and Equinox. https://docs.kidger.site/lineax
Python
344
star
8

sympy2jax

Turn SymPy expressions into trainable JAX expressions.
Python
313
star
9

optimistix

Nonlinear optimisation (root-finding, least squares, ...) in JAX+Equinox. https://docs.kidger.site/optimistix/
Python
299
star
10

signatory

Differentiable computations of the signature and logsignature transforms, on both CPU and GPU. (ICLR 2021)
C++
258
star
11

torchcubicspline

Interpolating natural cubic splines. Includes batching, GPU support, support for missing values, evaluating derivatives of the spline, and backpropagation.
Python
214
star
12

sympytorch

Turning SymPy expressions into PyTorch modules.
Python
139
star
13

quax

Multiple dispatch over abstract array types in JAX.
Python
100
star
14

Deep-Signature-Transforms

Code for "Deep Signature Transforms" (NeurIPS 2019)
Jupyter Notebook
87
star
15

FasterNeuralDiffEq

Code for "'Hey, that's not an ODE:' Faster ODE Adjoints via Seminorms" (ICML 2021)
Python
86
star
16

typst_pyimage

Typst extension, adding support for generating figures using inline Python code
Python
72
star
17

generalised_shapelets

Code for "Generalised Interpretable Shapelets for Irregular Time Series"
Jupyter Notebook
52
star
18

PatModules.jl

A better import/module system for Julia.
Julia
18
star
19

exvoker

A CLI tool. Extract regexes from stdout (e.g. URLs) and invoke commands on them (e.g. open the webpage).
Rust
9
star
20

action_update_python_project

Github Action to: Check version / Test / git tag / GitHub Release / Deploy to PyPI
8
star
21

pytkdocs_tweaks

Some custom tweaks to the results produced by pytkdocs.
Python
5
star
22

Learning-Interpolation

Applying machine learning to help numerically solve the Camassa-Holm equation.
Jupyter Notebook
4
star
23

matching

Round robin matching algorithm.
Python
3
star
24

candle

Simple PyTorch helpers. (I think we've probably all written one of these for ourselves!)
Python
3
star
25

tools

Helpful abstract tools (functions, classes, ... ) for coding in Python.
Python
3
star
26

pdfscraper

Saves a webpage and all linked pdfs.
Python
3
star
27

ktools

Tools for working with Keras.
Python
2
star
28

loccounter

Counts lines of Python code.
Python
2
star
29

Dissertation

Master's Dissertation: Polynomial Approximation of Holomorphic Functions
2
star
30

py2annotate

An extension to Sphinx autodoc to augment Sphinx documentation with type annotations, when using Python 2 style type annotations.
Python
2
star
31

adventuregame

The very start of a game I was toying with before I got distracted by the PhD...
Python
2
star
32

MPE-CDT-Project

A simple machine learning project for weather observations.
Jupyter Notebook
2
star
33

tfext

Some extra stuff for using with TensorFlow.
Python
2
star
34

mkdocs_include_exclude_files

Modify which files MkDocs includes or excludes.
Python
1
star
35

patrick-kidger

1
star
36

rl-test

Python
1
star