diff --git a/README.md b/README.md
index 7a62843da8c4fed75cdee400b786ec2ece842534..93941b3f9562f9f953f638cb3d15df811dd6d644 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,7 @@ pandoc:
     binder: true
     covers_dir: assets/covers
     signature: 20
+    full_file: true
 
     flags: '--smart'
     site_flags: '--toc'
@@ -58,6 +59,10 @@ pandoc:
 * `skip` allows you to skip the other formats generation and proceed with the
 regular jekyll site build.
 
+* `full_flags` if `full_file` is defined, these flags are used on it.
+  By default are set to `--top-level-division=part` so each category is
+  a different book part.
+
 * `site_flags` are flags applied to the html generation
 
 * `flags` is a string with the flags you will normally pass to `pandoc` on cli.
@@ -85,6 +90,9 @@ regular jekyll site build.
   Specify `0` for a single fold of all the pages.  You can also use this
   option on the front matter.
 
+* `full_file` generates a single file containing all articles, sectioned
+  by their main category (the first one defined if many).
+
 **IMPORTANT**: As of version 0.1.0 the syntax of the config changed.
 Please upgrade your `_config.yml` accordingly.
 
diff --git a/lib/jekyll-pandoc-multiple-formats/config.rb b/lib/jekyll-pandoc-multiple-formats/config.rb
index b88f8bbe446e244d32bd9f0c812151b28b693920..9ea839bc71f3354c747b4a92405d9bce28a45f8e 100644
--- a/lib/jekyll-pandoc-multiple-formats/config.rb
+++ b/lib/jekyll-pandoc-multiple-formats/config.rb
@@ -11,7 +11,9 @@ module JekyllPandocMultipleFormats
       'flags'             => '--smart',
       'site_flags'        => '--toc',
       'outputs'           => {},
-      'covers_dir'        => 'images/'
+      'covers_dir'        => 'images/',
+      'title'             => nil,
+      'full_flags'        => '--top-level-division=part'
     }
 
     attr_accessor :config
diff --git a/lib/jekyll-pandoc-multiple-formats/generator.rb b/lib/jekyll-pandoc-multiple-formats/generator.rb
index fd63bffa0a406cb9588de2cde2aa77f5c7a8b3c5..3c74dbcd261bbd29eaa5aab76d235a9ea0e096e9 100644
--- a/lib/jekyll-pandoc-multiple-formats/generator.rb
+++ b/lib/jekyll-pandoc-multiple-formats/generator.rb
@@ -50,6 +50,23 @@ class PandocGenerator < Generator
         @pandoc_files << pandoc_file
       end
 
+      if @config.full_file
+        # For parts to make sense, we order articles by date and then by
+        # category, so each category is ordered by date.
+        #
+        # cat1 - art1
+        # cat1 - art3
+        # cat2 - art2
+        full = @site.posts.docs.reject { |p| p.data.dig('full') }.sort_by do |p|
+          [ p.data['date'], p.data['categories'].first.to_s ]
+        end
+
+        full_file = PandocFile.new(@site, output, full, @site.config['title'], { full: true })
+        full_file.write
+        @site.keep_files << full_file.relative_path
+        @pandoc_files << full_file
+      end
+
       @site.post_attr_hash('categories').each_pair do |title, posts|
         posts.sort!
         pandoc_file = PandocFile.new(@site, output, posts, title)
diff --git a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
index e1fd709501737c84ac82b36cc481625e00c4dd6e..a670807656d713fb5f82ccd24a6ad55265a9e759 100644
--- a/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
+++ b/lib/jekyll-pandoc-multiple-formats/pandoc_file.rb
@@ -28,11 +28,13 @@ module Jekyll
     attr_reader :format, :site, :config, :flags, :posts, :slug, :title, :url
     attr_reader :papersize, :sheetsize, :signature
 
-    def initialize(site, format, posts, title = nil)
+    def initialize(site, format, posts, title = nil, extra = {})
       @site   = site
       @config = JekyllPandocMultipleFormats::Config.new(@site.config['pandoc']).config
       @format = format
       @flags  = []
+      @last_cat = nil
+      @extra = extra
 
       if posts.is_a? Array
         @single_post = false
@@ -45,7 +47,7 @@ module Jekyll
       else
         @single_post = true
         @posts = [posts]
-        @title = posts.data['title'] unless title
+        @title = title || posts.data['title']
         @slug  = posts.data['slug']
       end
 
@@ -150,7 +152,28 @@ module Jekyll
           # make all images relative to source dir
           content = content.gsub(relative_re, '(\1)')
 
-          content
+          # if the file contains all the articles, we make each category
+          # a different part by adding a first level title out of it
+          if full?
+            # make all titles down a level
+            # TODO have sixth level titles into account
+            content = content.gsub(/^#/, '##')
+
+            # we don't use all the categories otherwise the article
+            # would be repeated
+            cat = post.data['categories'].first
+            # if we already set the category part, we just skip it
+            if @last_cat == cat
+              content
+            # otherwise add the category title
+            else
+              @last_cat = cat
+              "# #{cat}\n\n#{content}"
+            end
+          else
+            # or we just return the content
+            content
+          end
         # we add the first bibliography title we can find in the end
         end.join("\n\n\n") << bib_title
       end
@@ -163,6 +186,7 @@ module Jekyll
       # Move to the source dir since everything will be relative to that
       Dir::chdir(@site.config['source']) do
         # Do the stuff
+        puts command
         Open3::popen3(command) do |stdin, stdout, stderr, thread|
           stdin.puts yaml_metadata
           stdin.puts content
@@ -225,6 +249,10 @@ module Jekyll
         @flags << cover
       end
 
+      if full?
+        @flags << @config['full_flags']
+      end
+
       @flags.join ' '
     end
 
@@ -232,6 +260,10 @@ module Jekyll
       'pandoc ' << flags
     end
 
+    def full?
+      @extra[:full]
+    end
+
     def pdf?
       @format == 'pdf'
     end