Giter Club home page Giter Club logo

pubcss's Introduction

PubCSS

PubCSS is a library of CSS stylesheets and HTML templates for formatting academic publications for print and the web.

Currently, the following formats are supported:

Check out sample output here.

Quick Start

  1. Create an HTML file, or modify the relevant template, to add your content
  2. Link your HTML to the relevant pub.css stylesheet
  3. Build to PDF using Prince with the command prince input.html output.pdf

The only dependency is Prince, which is free for non-commercial use.

Reference

Sections

Sections and subsections are automatically numbered by following this pattern.

<h1>Section Header</h1>
<section>
  <h2>Subsection Header</h2>
  <p>Lorem ipsum</p>
</section>

Tables and Figures

Figures and tables are also numbered if you include a caption.

<table>
  <tr><td>1</td><td>2</td></tr>
  <caption>Example Table</caption>
<table>

<figure>
  <img src="graph.png">
  <figcaption>Example Figure</figcaption>
</figure>

References and Citations

References are also numbered. Be sure to assign them unique IDs.

<cite id="nicole">Nicole. 2015. Title of paper. <em>Journal</em>, 4(3), 1-10.</cite>

Citations to the references make use of these IDs.

<a href="#nicole"></a>

Multiple citations can be made in one set of brackets.

<span class="cites"><a href="#beeker"></a><a href="#jackie"></a><a href="#kiwi"></a></span>

Sections, tables, and figures can also be referenced by adding a class.

<a href="#intro" class="section"></a>
<a href="#example-table" class="table"></a>
<a href="#example-figure" class="figure"></a>

Equations

Equations are also numbered. MathML is well-supported by Prince. For the web, you’ll need MathJax to render MathML properly in Chrome and Internet Explorer.

<div class="equation">
  <math xmlns="http://www.w3.org/1998/Math/MathML">
    <mi>E</mi>
    <mo>=</mo>
    <mi>m</mi>
    <msup>
      <mi>c</mi>
      <mn>2</mn>
    </msup>
  </math>
</div>

Footnotes

Footnotes are made within the body text, and are automatically moved to the bottom of the current page.

<p>This is text.<span class="footnote">And this is a footnote.</span></p>

Smart Quotes

Smart quotes can be used in lieu of straight quotes by enclosing the text like so. You can nest quotes within quotes.

<q>To be or not be.</q>

Utility Classes

Utility classes are also available to modify layout and counter behavior.

  • col-2: divide the element into 2 columns
  • col-3: divide the element into 3 columns
  • col-4: divide the element into 4 columns
  • col-span: span all of the columns of parent
  • col-break-before: force column break before element
  • col-break-after: force column break after element
  • page-break-before: force page break before element
  • page-break-after: force page break after element
  • counter-skip: do not count this header
  • counter-reset: reset counter to 0

Customization

One of the major advantages of PubCSS is that you can use CSS to customize the style. All of the usual rules apply.

To create a new theme, you’ll want to dig into the LESS source. The most common changes can be made through variables.less, such as toggling page numbers and setting counter styles. The rest can be included in custom.less.

pubcss's People

Contributors

ahmad88me avatar cbleslie avatar dependabot[bot] avatar thomaspark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pubcss's Issues

Equations don't render in Chrome on Windows or Android

Hi Thomas – The equations in section 2.2 don't render properly in Chrome 50 (64-bit) on Windows 10 (64-bit). They flash into existence for a second or less, then disappear. MathJax should work fine with Chrome, so I'm stumped by this one.

Section 2.6 is similarly broken in Chrome, except that part of Definition 1 displays. The e term is gone, so it just displays "log = z".

I just checked on my phone, and it's the same behavior. Chrome 50 on Android 6.01 briefly displays the equations, but once I scrolled past them and then back up to them, they were gone.

footnote is not HTML

The footnote element as mentioned in http://thomaspark.me/2015/01/pubcss-formatting-academic-publications-in-html-css/ is not a valid HTML element. Such element exists in neither http://developers.whatwg.org nor http://www.w3.org/TR/html5/ nor http://www.w3.org/TR/html51/

You might take some ideas from the HTML footnote syntax that Pandoc outputs:

<p>This is a reference to a note<a href="#fn1" class="footnoteRef" id="fnref1"><sup>1</sup></a></p>

<section class="footnotes">
    <hr />
    <ol>
        <li id="fn1"><p>This is a note<a href="#fnref1"></a></p></li>
    </ol>
</section>

which is incidentally similar to MultiMarkdown's:

<p>This is a reference to a note<a href="#fn:1" id="fnref:1" title="see footnote" class="footnote">[1]</a></p>

<div class="footnotes">
    <hr />
    <ol>
        <li id="fn:1"><p>This is a note <a href="#fnref:1" title="return to article" class="reversefootnote">&#160;&#8617;</a></p></li>
    </ol>
</div>

I, for one, prefer Pandoc's, since Multimarkdown's requires escaping the colon character in CSS selectors I also find Multimarkdown's use of brackets wrapping the reference an arbitrary aesthetic decision (not that Pandoc's decision to wrap it in a superscript is any less arbitrary, but at least I can CSS-style that away).

Port pubcss from LESS to Sass

With the industry moving away from LESS and closer to Sass (Bootstrap v4 coming out in Sass), it looks like the industry heavyweights are placing their bets on Sass.

I'd be interested in issuing a PR for release 0.3.0 with the following.

  1. Porting code from LESS to Sass
  2. Implementing a build system (Grunt, Gulp, etc)
  3. Publishing pubcss in the bower package registry.

🚀

pubcss-ieee.css:166: warning: missing ':'

prince: css/pubcss-ieee.css:166: warning: missing ':' for pseudo-element '::footnote-call'
prince: css/pubcss-ieee.css:171: warning: missing ':' for pseudo-element '::footnote-marker'
prince: css/pubcss-ieee.css:177: warning: parse error in page declaration at 'escape('
prince: css/pubcss-ieee.css:387: warning: missing ':' for pseudo-element '::footnote-call'

Author columns broken on Firefox

Hi Thomas – The three-column author layout in the ACM sample breaks in Firefox desktop (FF 46 on Windows 10). Authors Tobin and Thorvald have their institutional and contact info one column over from their names, as you can see in this screenshot on Imgur.

It displays correctly in Chrome 50 on Windows 10, and mostly correct in Chrome 50 on Android 6 and Firefox 46 on Android 6. In both Android cases, the e-mail addresses either get truncated (Chrome) or overlap becoming a bolded mishmash (Firefox), but authors and their info stay together in the correct columns.

By the way, the page dimensions in the first paragraph of the ACM sample should use the double prime character to look best (and to be semantically correct), e.g. 7″ instead of 7". (The glyph is U+2033).

Consider using explicit markup for each section to avoid numbering-related classes

If the template wraps each section explicitly in a <section> tag, and uses h1, h2, etc + section > section > … to indicate the depth of nesting, then it's possible to avoid all the .counter-skip classes by only applying the numbering to headings inside section elements.

Here's an example: master...hubgit:explicit-sections

The article layout basically looks like this:

<article>
  <header>
    <h1>Article Title</h1>
    <div></div>
  </header>

  <section>
    <h2>Section heading</h2>
    <p></p>
  </section>

  <section>
    <h2>Section heading</h2>
    <p></p>

    <section>
      <h3>Subsection heading</h3>
      <p></p>
    </section>

    <section>
      <h3>Subsection heading</h3>
      <p></p>
    </section>
  </section>

  <footer>
    <div></div>
  </footer>
</article>

Prince to(/vs) wkhtml

You recommend using prince for your html to pdf conversion but, that is a paid service and, for non-commercial adds a watermark. Have you considered wkhtml? It's free, in every test I've don't it seems flawless and it's in the debian repository which makes it easy on linux.

Use puppeteer for generating the PDF's?

I figure we could make a gulp build, and run puppeteer (headless chrome) to export the PDF's? Thoughts?

https://github.com/GoogleChrome/puppeteer has an example of creating a PDF from a page:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle2'});
  await page.pdf({path: 'hn.pdf', format: 'A4'});

  await browser.close();
})();

Addtional docs: https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions

Errors when trying to compile custom version.

Hello,

I need to create my own css, because I need to use a different (and quite obscure) standard than what you have. It is not a problem for me to setup the styles accordingly, but I can't get even your unmodified code to compile. When I first tried to run sass, it returned:

Error: Invalid CSS after "escape": expected selector, was "("@")footnotes"
        on line 2 of pubcss/src/objects/_footnotes.scss, in `footnotes'
        from line 11 of pubcss/src/objects/_page.scss
        from line 25 of pubcss/src/_manifest.scss
        from line 5 of styles/pubcss-gjsm.scss
  Use --trace for backtrace.

I looked into the source and tried to replace the escape function with the unquote function, which throws this error:

Error: Invalid CSS after "": expected selector, was "@footnotes"
        on line 2 of pubcss/src/objects/_footnotes.scss, in `footnotes'
        from line 11 of pubcss/src/objects/_page.scss
        from line 25 of pubcss/src/_manifest.scss
        from line 5 of styles/pubcss-gjsm.scss
  Use --trace for backtrace.

I suspect this might be because I don't use Gulp, which I would like to avoid, because from what I understand it is used just for automatic reloading of the css in a browser, which I have my own tools for and don't really need for this project.

Or does this have something to do with Price?

Is there a way I could quickly patch/fix this without too much pain?

Thank you very much,
GS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.