Browse Source

org-table.el: Add defcustoms for LaTeX export of table rules :tstart, :hline and :tend

* org-table.el (orgtbl-to-generic): Add check for :skipheadrule.
When present, the :hline following the head will be skipped.  This is
necessary to avoid doubling of horizontal rules in LaTeX longtable
environments and consequent width problems.

* org-latex.el (org-export-latex-tables-tstart)
(org-export-latex-tables-hline)
(org-export-latex-tables-tend): New options.
(org-export-latex-tables): Use the new options.
niels giesen 13 years ago
parent
commit
549c498bb6
2 changed files with 39 additions and 5 deletions
  1. 37 4
      lisp/org-latex.el
  2. 2 1
      lisp/org-table.el

+ 37 - 4
lisp/org-latex.el

@@ -377,6 +377,33 @@ When nil, grouping causes only separation lines between groups."
   :group 'org-export-latex
   :type 'boolean)
 
+(defcustom org-export-latex-tables-tstart nil
+  "LaTeX command for top rule for tables."
+  :group 'org-export-latex
+  :version "24.1"
+  :type '(choice
+          (const :tag "Nothing" nil)
+          (string :tag "String")
+          (const  :tag "Booktabs default: \\toprule" "\\toprule")))
+
+(defcustom org-export-latex-tables-hline "\\hline"
+  "LaTeX command to use for a rule somewhere in the middle of a table."
+  :group 'org-export-latex
+  :version "24.1"
+  :type '(choice
+          (string :tag "String")
+          (const  :tag "Standard: \\hline" "\\hline")
+          (const  :tag "Booktabs default: \\midrule" "\\midrule")))
+
+(defcustom org-export-latex-tables-tend nil
+  "LaTeX command for bottom rule for tables."
+  :group 'org-export-latex
+  :version "24.1"
+  :type '(choice
+          (const :tag "Nothing" nil)
+          (string :tag "String")
+          (const  :tag "Booktabs default: \\bottomrule" "\\bottomrule")))
+
 (defcustom org-export-latex-low-levels 'itemize
   "How to convert sections below the current level of sectioning.
 This is specified by the `org-export-headline-levels' option or the
@@ -2053,14 +2080,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 				    align))
                         (orgtbl-to-latex
                          lines
-                         `(:tstart nil :tend nil
+                         `(:tstart ,org-export-latex-tables-tstart
+				   :tend ,org-export-latex-tables-tend
+				   :hline ,org-export-latex-tables-hline
+                                   :skipheadrule ,longtblp
                                    :hlend ,(if longtblp
                                                (format "\\\\
-\\hline
+%s
 \\endhead
-\\hline\\multicolumn{%d}{r}{Continued on next page}\\
+%s\\multicolumn{%d}{r}{Continued on next page}\\
 \\endfoot
-\\endlastfoot" (length org-table-last-alignment))
+\\endlastfoot"
+                                           org-export-latex-tables-hline
+                                           org-export-latex-tables-hline
+                                           (length org-table-last-alignment))
                                              nil)))
                         (if (not longtblp) (format "\n\\end{%s}" tabular-env))
                         (if longtblp "\n" (if org-export-latex-tables-centered

+ 2 - 1
lisp/org-table.el

@@ -4514,6 +4514,7 @@ directly by `orgtbl-send-table'.  See manual."
 
   (let* ((splicep (plist-get params :splice))
 	 (hline (plist-get params :hline))
+	 (skipheadrule (plist-get params :skipheadrule))
 	 (remove-nil-linesp (plist-get params :remove-nil-lines))
 	 (remove-newlines (plist-get params :remove-newlines))
 	 (*orgtbl-hline* hline)
@@ -4559,7 +4560,7 @@ directly by `orgtbl-send-table'.  See manual."
 		 (*orgtbl-sep* (or (plist-get params :hlsep) *orgtbl-sep*))
 		 (*orgtbl-fmt* (or (plist-get params :hfmt) *orgtbl-fmt*)))
 	    (orgtbl-format-section 'hline))
-	  (if hline (push hline *orgtbl-rtn*))
+	  (if (and hline (not skipheadrule)) (push hline *orgtbl-rtn*))
 	  (pop *orgtbl-table*)))
 
     ;; Now format the main section.