stockor 0.1.9 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (313) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +254 -72
  4. data/Guardfile +1 -1
  5. data/README.md +24 -3
  6. data/app.json +28 -0
  7. data/client/skr/Extension.coffee +18 -0
  8. data/client/skr/components/BankAccountFinder.cjsx +34 -0
  9. data/client/skr/components/Currency.cjsx +19 -0
  10. data/client/skr/components/CustomerFinder.cjsx +37 -0
  11. data/client/skr/components/CustomerLink.cjsx +13 -0
  12. data/client/skr/components/CustomerProjectFinder.cjsx +49 -0
  13. data/client/skr/components/GlAccountChooser.cjsx +38 -0
  14. data/client/skr/components/InvoiceFinder.cjsx +37 -0
  15. data/client/skr/components/InvoiceLink.cjsx +13 -0
  16. data/client/skr/components/LocationChooser.cjsx +37 -0
  17. data/client/skr/components/PaymentCategoryFinder.cjsx +34 -0
  18. data/client/skr/components/PrintFormChooser.cjsx +29 -0
  19. data/client/skr/components/SalesOrderFinder.cjsx +38 -0
  20. data/client/skr/components/ScreenControls.cjsx +20 -0
  21. data/client/skr/components/SkuFinder.cjsx +30 -0
  22. data/client/skr/components/SkuLines.cjsx +76 -0
  23. data/client/skr/components/SystemSettings.cjsx +26 -0
  24. data/client/skr/components/TermsChooser.cjsx +40 -0
  25. data/client/skr/components/ToolbarButton.cjsx +7 -0
  26. data/client/skr/components/TotalsLine.cjsx +21 -0
  27. data/client/skr/components/TriStateIcon.cjsx +12 -0
  28. data/client/skr/components/UOMChooser.cjsx +24 -0
  29. data/client/skr/components/UserPreferences.cjsx +30 -0
  30. data/client/skr/components/VendorFinder.cjsx +40 -0
  31. data/client/skr/components/address/Address.cjsx +10 -10
  32. data/client/skr/components/styles.scss +16 -0
  33. data/client/skr/index.js +3 -1
  34. data/client/skr/models/Address.coffee +9 -1
  35. data/client/skr/models/BankAccount.coffee +17 -0
  36. data/client/skr/models/Base.coffee +6 -0
  37. data/client/skr/models/Customer.coffee +17 -10
  38. data/client/skr/models/CustomerProject.coffee +29 -0
  39. data/client/skr/models/GlAccount.coffee +22 -10
  40. data/client/skr/models/GlManualEntry.coffee +4 -2
  41. data/client/skr/models/GlPeriod.coffee +4 -6
  42. data/client/skr/models/GlPosting.coffee +7 -7
  43. data/client/skr/models/GlTransaction.coffee +3 -3
  44. data/client/skr/models/IaLine.coffee +9 -9
  45. data/client/skr/models/IaReason.coffee +4 -4
  46. data/client/skr/models/InvLine.coffee +30 -11
  47. data/client/skr/models/InventoryAdjustment.coffee +8 -6
  48. data/client/skr/models/Invoice.coffee +89 -18
  49. data/client/skr/models/Location.coffee +27 -6
  50. data/client/skr/models/Payment.coffee +36 -0
  51. data/client/skr/models/PaymentCategory.coffee +12 -0
  52. data/client/skr/models/PaymentTerm.coffee +17 -4
  53. data/client/skr/models/PickTicket.coffee +7 -5
  54. data/client/skr/models/PoLine.coffee +15 -15
  55. data/client/skr/models/PoReceipt.coffee +8 -6
  56. data/client/skr/models/PorLine.coffee +11 -11
  57. data/client/skr/models/PricingProvider.coffee +6 -0
  58. data/client/skr/models/PtLine.coffee +13 -13
  59. data/client/skr/models/PurchaseOrder.coffee +11 -9
  60. data/client/skr/models/SalesOrder.coffee +59 -22
  61. data/client/skr/models/Sku.coffee +17 -15
  62. data/client/skr/models/SkuLoc.coffee +14 -9
  63. data/client/skr/models/SkuTran.coffee +10 -10
  64. data/client/skr/models/SkuVendor.coffee +9 -9
  65. data/client/skr/models/SoLine.coffee +27 -20
  66. data/client/skr/models/TimeEntry.coffee +75 -0
  67. data/client/skr/models/Uom.coffee +27 -6
  68. data/client/skr/models/Vendor.coffee +14 -12
  69. data/client/skr/models/VoLine.coffee +11 -11
  70. data/client/skr/models/Voucher.coffee +7 -5
  71. data/client/skr/models/mixins/HasVisibleId.coffee +7 -0
  72. data/client/skr/models/mixins/PrintSupport.coffee +6 -0
  73. data/client/skr/models/mixins/SkuLine.coffee +61 -0
  74. data/client/skr/screens/Commands.coffee +29 -0
  75. data/client/skr/screens/bank-maint/BankMaint.cjsx +43 -0
  76. data/client/skr/screens/bank-maint/index.js +5 -0
  77. data/client/skr/screens/chart-of-accounts/ChartOfAccounts.cjsx +40 -0
  78. data/client/skr/screens/chart-of-accounts/index.js +1 -0
  79. data/client/skr/screens/chart-of-accounts/index.scss +12 -0
  80. data/client/skr/screens/customer-maint/CustomerMaint.cjsx +35 -36
  81. data/client/skr/screens/customer-projects/CustomerProjects.cjsx +70 -0
  82. data/client/skr/screens/customer-projects/index.js +5 -0
  83. data/client/skr/screens/customer-projects/index.scss +25 -0
  84. data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +35 -0
  85. data/client/skr/screens/fresh-books-import/ChooseRecords.cjsx +116 -0
  86. data/client/skr/screens/fresh-books-import/FreshBooksImport.cjsx +31 -0
  87. data/client/skr/screens/fresh-books-import/Import.coffee +52 -0
  88. data/client/skr/screens/fresh-books-import/ViewRecords.cjsx +96 -0
  89. data/client/skr/screens/fresh-books-import/index.js +1 -0
  90. data/client/skr/screens/fresh-books-import/index.scss +39 -0
  91. data/client/skr/screens/gl-accounts/GlAccounts.cjsx +31 -0
  92. data/client/skr/screens/gl-accounts/index.js +5 -0
  93. data/client/skr/screens/gl-transactions/GlTransactions.cjsx +46 -0
  94. data/client/skr/screens/gl-transactions/index.js +1 -0
  95. data/client/skr/screens/gl-transactions/index.scss +12 -0
  96. data/client/skr/screens/invoice/Invoice.cjsx +92 -0
  97. data/client/skr/screens/invoice/Payment.cjsx +28 -0
  98. data/client/skr/screens/invoice/index.js +5 -0
  99. data/client/skr/screens/locations/Locations.cjsx +31 -0
  100. data/client/skr/screens/locations/index.js +5 -0
  101. data/client/skr/screens/payment-category/PaymentCategory.cjsx +28 -0
  102. data/client/skr/screens/payment-category/index.js +5 -0
  103. data/client/skr/screens/payment-category/index.scss +9 -0
  104. data/client/skr/screens/payment-terms/PaymentTerms.cjsx +28 -0
  105. data/client/skr/screens/payment-terms/index.js +5 -0
  106. data/client/skr/screens/payment-terms/index.scss +9 -0
  107. data/client/skr/screens/payments/Payments.cjsx +59 -0
  108. data/client/skr/screens/payments/index.js +5 -0
  109. data/client/skr/screens/sales-order/SalesOrder.cjsx +68 -0
  110. data/client/skr/screens/sales-order/index.js +1 -5
  111. data/client/skr/screens/sku-maint/SkuMaint.cjsx +53 -0
  112. data/client/skr/screens/sku-maint/SkuUomList.cjsx +209 -0
  113. data/client/skr/screens/sku-maint/index.js +2 -5
  114. data/client/skr/screens/sku-maint/index.scss +37 -6
  115. data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +156 -0
  116. data/client/skr/screens/time-invoicing/index.js +5 -0
  117. data/client/skr/screens/time-invoicing/index.scss +7 -0
  118. data/client/skr/screens/time-tracking/EditEntry.cjsx +54 -0
  119. data/client/skr/screens/time-tracking/Entries.coffee +132 -0
  120. data/client/skr/screens/time-tracking/Header.cjsx +71 -0
  121. data/client/skr/screens/time-tracking/Popover.cjsx +70 -0
  122. data/client/skr/screens/time-tracking/PopoverMiniControls.cjsx +25 -0
  123. data/client/skr/screens/time-tracking/TimeTracking.cjsx +63 -0
  124. data/client/skr/screens/time-tracking/WeekSummary.cjsx +16 -0
  125. data/client/skr/screens/time-tracking/index.js +1 -0
  126. data/client/skr/screens/time-tracking/index.scss +126 -0
  127. data/client/skr/screens/vendor-maint/VendorMaint.cjsx +45 -0
  128. data/client/skr/screens/vendor-maint/index.js +1 -5
  129. data/client/skr/styles.scss +1 -13
  130. data/config/puma.rb +4 -0
  131. data/config/routes.rb +21 -9
  132. data/config/screens.rb +147 -32
  133. data/db/migrate/20140202194700_create_skr_gl_transaction_details.rb +35 -0
  134. data/db/migrate/20140220031800_create_skr_locations.rb +2 -0
  135. data/db/migrate/20140220190836_create_skr_vendors.rb +1 -0
  136. data/db/migrate/20140220203029_create_skr_customers.rb +3 -2
  137. data/db/migrate/20140224034759_create_skr_skus.rb +2 -3
  138. data/db/migrate/20140322223912_create_skr_sales_orders.rb +4 -3
  139. data/db/migrate/20140322223920_create_skr_so_lines.rb +4 -5
  140. data/db/migrate/20140323001446_create_so_details_view.rb +7 -5
  141. data/db/migrate/20140327202209_create_skr_pt_lines.rb +2 -2
  142. data/db/migrate/20140327214000_create_customer_project.rb +16 -0
  143. data/db/migrate/20140327223002_create_time_entries.rb +17 -0
  144. data/db/migrate/20140327224000_create_skr_invoices.rb +5 -1
  145. data/db/migrate/20140327224002_create_skr_inv_lines.rb +3 -1
  146. data/db/migrate/20140422024010_create_skr_inv_details_view.rb +1 -1
  147. data/db/migrate/20151121211323_create_customer_project_details_views.rb +31 -0
  148. data/db/migrate/20160216142845_create_gl_account_balances_view.rb +20 -0
  149. data/db/migrate/20160229002044_create_bank_accounts.rb +18 -0
  150. data/db/migrate/20160229041711_create_payments.rb +33 -0
  151. data/db/migrate/20160307022705_create_create_combined_uom_views.rb +18 -0
  152. data/db/schema.sql +639 -140
  153. data/db/seed/chart_of_accounts.yml +8 -6
  154. data/db/seed/payment_categories.yml +12 -0
  155. data/db/seed/skus.yml +32 -0
  156. data/db/seed.rb +21 -0
  157. data/lib/skr/access_roles.rb +19 -6
  158. data/lib/skr/concerns/has_sku_loc_lines.rb +0 -16
  159. data/lib/skr/concerns/inv_extensions.rb +24 -0
  160. data/lib/skr/concerns/is_sku_loc_line.rb +3 -4
  161. data/lib/skr/concerns/so_extensions.rb +8 -0
  162. data/lib/skr/concerns/visible_id_identifier.rb +1 -1
  163. data/lib/skr/db/migration_helpers.rb +2 -4
  164. data/lib/skr/extension.rb +11 -4
  165. data/lib/skr/handlers/fresh_books_import.rb +20 -0
  166. data/lib/skr/handlers/invoice_from_time_entries.rb +49 -0
  167. data/lib/skr/jobs/fresh_books/base.rb +54 -0
  168. data/lib/skr/jobs/fresh_books/import.rb +151 -0
  169. data/lib/skr/jobs/fresh_books/retrieve.rb +62 -0
  170. data/lib/skr/model.rb +5 -0
  171. data/lib/skr/models/address.rb +1 -1
  172. data/lib/skr/models/bank_account.rb +13 -0
  173. data/lib/skr/models/business_entity.rb +3 -0
  174. data/lib/skr/models/customer.rb +1 -1
  175. data/lib/skr/models/customer_project.rb +22 -0
  176. data/lib/skr/models/gl_account.rb +13 -3
  177. data/lib/skr/models/gl_period.rb +6 -0
  178. data/lib/skr/models/gl_posting.rb +7 -4
  179. data/lib/skr/models/gl_transaction.rb +19 -33
  180. data/lib/skr/models/ia_line.rb +1 -1
  181. data/lib/skr/models/inv_line.rb +33 -15
  182. data/lib/skr/models/invoice.rb +47 -20
  183. data/lib/skr/models/location.rb +7 -1
  184. data/lib/skr/models/payment.rb +49 -0
  185. data/lib/skr/models/payment_category.rb +11 -0
  186. data/lib/skr/models/payment_term.rb +1 -1
  187. data/lib/skr/models/por_line.rb +1 -1
  188. data/lib/skr/models/pt_line.rb +1 -1
  189. data/lib/skr/models/sales_order.rb +9 -9
  190. data/lib/skr/models/sku_loc.rb +1 -1
  191. data/lib/skr/models/sku_tran.rb +6 -11
  192. data/lib/skr/models/so_line.rb +22 -12
  193. data/lib/skr/models/time_entry.rb +36 -0
  194. data/lib/skr/models/uom.rb +11 -10
  195. data/lib/skr/models/user_proxy.rb +1 -1
  196. data/lib/skr/number.rb +25 -0
  197. data/lib/skr/print/form.rb +46 -0
  198. data/lib/skr/print/template.rb +48 -0
  199. data/lib/skr/print.rb +11 -0
  200. data/lib/skr/string.rb +11 -0
  201. data/lib/skr/version.rb +1 -1
  202. data/lib/skr.rb +9 -0
  203. data/spec/fixtures/skr/address.yml +164 -4
  204. data/spec/fixtures/skr/bank_account.yml +8 -0
  205. data/spec/fixtures/skr/customer.yml +30 -4
  206. data/spec/fixtures/skr/customer_project.yml +20 -0
  207. data/spec/fixtures/skr/gl_account.yml +19 -1
  208. data/spec/fixtures/skr/gl_period.yml +3 -0
  209. data/spec/fixtures/skr/gl_posting.yml +22 -1
  210. data/spec/fixtures/skr/gl_transaction.yml +4 -1
  211. data/spec/fixtures/skr/inv_line.yml +35 -0
  212. data/spec/fixtures/skr/invoice.yml +13 -2
  213. data/spec/fixtures/skr/location.yml +5 -0
  214. data/spec/fixtures/skr/payment.yml +10 -0
  215. data/spec/fixtures/skr/payment_category.yml +8 -0
  216. data/spec/fixtures/skr/payment_term.yml +37 -3
  217. data/spec/fixtures/skr/sales_order.yml +12 -1
  218. data/spec/fixtures/skr/sku.yml +78 -1
  219. data/spec/fixtures/skr/sku_loc.yml +42 -1
  220. data/spec/fixtures/skr/sku_tran.yml +24 -1
  221. data/spec/fixtures/skr/so_line.yml +32 -0
  222. data/spec/fixtures/skr/time_entry.yml +82 -0
  223. data/spec/fixtures/skr/uom.yml +52 -1
  224. data/spec/fixtures/skr/vendor.yml +28 -1
  225. data/spec/fixtures/stockor.png +0 -0
  226. data/spec/server/bank_account_spec.rb +10 -0
  227. data/spec/server/customer_project_spec.rb +10 -0
  228. data/spec/server/handlers/invoice_from_time_entries_spec.rb +49 -0
  229. data/spec/server/jobs/fresh_books/import_spec.rb +69 -0
  230. data/spec/server/jobs/fresh_books/retrieve_spec.rb +37 -0
  231. data/spec/server/models/address_spec.rb +4 -3
  232. data/spec/server/models/gl_transaction_spec.rb +3 -3
  233. data/spec/server/models/inv_line_spec.rb +83 -3
  234. data/spec/server/models/invoice_spec.rb +32 -3
  235. data/spec/server/models/payment_spec.rb +40 -0
  236. data/spec/server/models/sales_order_spec.rb +1 -1
  237. data/spec/server/models/so_line_spec.rb +3 -3
  238. data/spec/server/models/spec_helper_spec.rb +1 -1
  239. data/spec/server/payment_spec.rb +10 -0
  240. data/spec/server/print/form_spec.rb +47 -0
  241. data/spec/server/print/template_spec.rb +36 -0
  242. data/spec/server/spec_helper.rb +14 -1
  243. data/spec/server/time_entry_spec.rb +10 -0
  244. data/spec/skr/components/SkuLinesSpec.coffee +61 -0
  245. data/spec/skr/models/BankAccountSpec.coffee +5 -0
  246. data/spec/skr/models/CustomerProjectSpec.coffee +5 -0
  247. data/spec/skr/models/CustomerSpec.coffee +2 -2
  248. data/spec/skr/models/PaymentSpec.coffee +5 -0
  249. data/spec/skr/models/SalesOrderSpec.coffee +21 -5
  250. data/spec/skr/models/SoLineSpec.coffee +7 -2
  251. data/spec/skr/models/TimeEntrySpec.coffee +5 -0
  252. data/spec/skr/screens/bank-maint/BankMaintSpec.coffee +5 -0
  253. data/spec/skr/screens/customer-projects/CustomerProjectsSpec.coffee +5 -0
  254. data/spec/skr/screens/fresh-books-import/FreshBooksImportSpec.coffee +1 -0
  255. data/spec/skr/screens/gl-accounts/GlAccountsSpec.coffee +5 -0
  256. data/spec/skr/screens/invoice/InvoiceSpec.coffee +5 -0
  257. data/spec/skr/screens/locations/LocationsSpec.coffee +5 -0
  258. data/spec/skr/screens/payment-category/PaymentCategorySpec.coffee +5 -0
  259. data/spec/skr/screens/payment-terms/PaymentTermsSpec.coffee +5 -0
  260. data/spec/skr/screens/payments/PaymentsSpec.coffee +5 -0
  261. data/spec/skr/screens/time-invoicing/TimeInvoicingSpec.coffee +5 -0
  262. data/spec/skr/screens/time-tracking/TimeTrackingSpec.coffee +14 -0
  263. data/spec/vcr/freshbooks.yml +698 -0
  264. data/stockor.gemspec +5 -1
  265. data/templates/print/fonts/GnuMICR.otf +0 -0
  266. data/templates/print/layout.tex.erb +39 -0
  267. data/templates/print/packages/booktabs.sty +182 -0
  268. data/templates/print/packages/fancybox.sty +966 -0
  269. data/templates/print/packages/fancyhdr.sty +485 -0
  270. data/templates/print/packages/graphbox.sty +129 -0
  271. data/templates/print/packages/lastpage.sty +283 -0
  272. data/templates/print/packages/lastpage209.sty +70 -0
  273. data/templates/print/packages/marginnote.sty +412 -0
  274. data/templates/print/packages/multirow.sty +159 -0
  275. data/templates/print/packages/rotating.sty +282 -0
  276. data/templates/print/packages/tabu.sty +2557 -0
  277. data/templates/print/packages/textpos.sty +361 -0
  278. data/templates/print/packages/varwidth.sty +318 -0
  279. data/templates/print/partials/address.tex.erb +6 -0
  280. data/templates/print/partials/bill_to_ship_to.tex.erb +13 -0
  281. data/templates/print/partials/header.tex.erb +13 -0
  282. data/templates/print/partials/invoice_paid_state.tex.erb +2 -0
  283. data/templates/print/partials/old/inv_lines_grouping.tex.erb +8 -0
  284. data/templates/print/partials/old/labor_lines_footer.tex.erb +18 -0
  285. data/templates/print/partials/skus_table.tex.erb +32 -0
  286. data/templates/print/partials/skus_table_col_hdr.tex.erb +8 -0
  287. data/templates/print/partials/skus_table_footer.tex.erb +5 -0
  288. data/templates/print/partials/skus_table_group_footer.tex.erb +4 -0
  289. data/templates/print/partials/skus_table_invoice_footer.tex.erb +25 -0
  290. data/templates/print/partials/skus_table_invoice_info_line.tex.erb +16 -0
  291. data/templates/print/partials/skus_table_labor_col_hdr.tex.erb +8 -0
  292. data/templates/print/partials/skus_table_labor_group_footer.tex.erb +7 -0
  293. data/templates/print/partials/skus_table_labor_line.tex.erb +11 -0
  294. data/templates/print/partials/skus_table_line.tex.erb +6 -0
  295. data/templates/print/partials/skus_table_other_charge_lines.tex.erb +7 -0
  296. data/templates/print/partials/so_info_line.tex.erb +14 -0
  297. data/templates/print/types/invoice/default.tex.erb +13 -0
  298. data/templates/print/types/invoice/labor.tex.erb +33 -0
  299. data/templates/print/types/payment/default.tex.erb +64 -0
  300. data/templates/print/types/sales-order/default.tex.erb +8 -0
  301. metadata +252 -15
  302. data/client/skr/components/address/address.html +0 -20
  303. data/client/skr/models/mixins/CodeField.coffee +0 -5
  304. data/client/skr/screens/customer-maint/index.scss +0 -11
  305. data/client/skr/screens/customer-maint/layout.html +0 -32
  306. data/client/skr/screens/sales-order/SalesOrder.coffee +0 -30
  307. data/client/skr/screens/sales-order/index.scss +0 -8
  308. data/client/skr/screens/sales-order/layout.html +0 -30
  309. data/client/skr/screens/sku-maint/SkuMaint.coffee +0 -18
  310. data/client/skr/screens/sku-maint/layout.html +0 -16
  311. data/client/skr/screens/vendor-maint/VendorMaint.coffee +0 -28
  312. data/client/skr/screens/vendor-maint/index.scss +0 -8
  313. data/client/skr/screens/vendor-maint/layout.html +0 -32
@@ -0,0 +1,2557 @@
1
+ %%
2
+ %% This is file `tabu.sty',
3
+ %% generated with the docstrip utility.
4
+ %%
5
+ %% The original source files were:
6
+ %%
7
+ %% tabu.dtx (with options: `package')
8
+ %%
9
+ %% This is a generated file.
10
+ %% Copyright (FC) 2010-2011 - lppl
11
+ %%
12
+ %% tabu : 2011/02/26 v2.8 - tabu : Flexible LaTeX tabulars
13
+ %%
14
+ %% **********************************************************************************************
15
+ %% \begin{tabu} { preamble } => default target: \linewidth or \linegoal
16
+ %% \begin{tabu} to <dimen>{ preamble } => target specified
17
+ %% \begin{tabu} spread <dimen>{ preamble } => target relative to the ``natural width''
18
+ %%
19
+ %% tabu works in text and in math modes.
20
+ %%
21
+ %% X columns: automatic width ajustment + horizontal and vertical alignment
22
+ %% \begin{tabu} { X[4c] X[1c] X[-2ml] }
23
+ %%
24
+ %% Horizontal lines and / or leaders:
25
+ %% \hline\hline => double horizontal line
26
+ %% \firsthline\hline => for nested tabulars
27
+ %% \lasthline\hline => for nested tabulars
28
+ %% \tabucline[line spec]{column-column} => ``funny'' lines (dash/leader)
29
+ %% Automatic lines / leaders :
30
+ %% \everyrow{\hline\hline}
31
+ %%
32
+ %% Vertical lines and / or leaders:
33
+ %% \begin{tabu} { |[3pt red] X[4c] X[1c] X[-2ml] |[3pt blue] }
34
+ %% \begin{tabu} { |[3pt red] X[4c] X[1c] X[-2ml] |[3pt on 2pt off 4pt blue] }
35
+ %%
36
+ %% Fixed vertical spacing adjustment:
37
+ %% \extrarowheight=<dimen> \extrarowdepth=<dimen>
38
+ %% or: \extrarowsep=<dimen> => may be prefixed by \global
39
+ %%
40
+ %% Dynamic vertical spacing adjustment:
41
+ %% \abovetabulinesep=<dimen> \belowtabulinesep=<dimen>
42
+ %% or: \tabulinesep=<dimen> => may be prefixed by \global
43
+ %%
44
+ %% delarray.sty shortcuts: in math and text modes
45
+ %% \begin{tabu} .... \({ preamble }\)
46
+ %%
47
+ %% Algorithms reports:
48
+ %% \tracingtabu=1 \tracingtabu=2
49
+ %%
50
+ %% **********************************************************************************************
51
+ %%
52
+ %% This work may be distributed and/or modified under the
53
+ %% conditions of the LaTeX Project Public License, either
54
+ %% version 1.3 of this license or (at your option) any later
55
+ %% version. The latest version of this license is in
56
+ %% http://www.latex-project.org/lppl.txt
57
+ %%
58
+ %% This work consists of the main source file tabu.dtx
59
+ %% and the derived files
60
+ %% tabu.sty, tabu.pdf, tabu.ins
61
+ %%
62
+ %% tabu : Flexible LaTeX tabulars
63
+ %% lppl copyright 2010-2011 by FC <florent.chervet@free.fr>
64
+ %%
65
+
66
+ \NeedsTeXFormat{LaTeX2e}[2005/12/01]
67
+ \ProvidesPackage{tabu}[2011/02/26 v2.8 - flexible LaTeX tabulars (FC)]
68
+ \RequirePackage{array}[2008/09/09]
69
+ \RequirePackage{varwidth}[2009/03/30]
70
+ \AtEndOfPackage{\tabu@AtEnd \let\tabu@AtEnd \@undefined}
71
+ \let\tabu@AtEnd\@empty
72
+ \def\TMP@EnsureCode#1={%
73
+ \edef\tabu@AtEnd{\tabu@AtEnd
74
+ \catcode#1 \the\catcode#1}%
75
+ \catcode#1=%
76
+ }% \TMP@EnsureCode
77
+ \TMP@EnsureCode 33 = 12 % !
78
+ \TMP@EnsureCode 58 = 12 % : (for siunitx)
79
+ \TMP@EnsureCode124 = 12 % |
80
+ \TMP@EnsureCode 36 = 3 % $ = math shift
81
+ \TMP@EnsureCode 38 = 4 % & = tab alignmment character
82
+ \TMP@EnsureCode 32 = 10 % space
83
+ \TMP@EnsureCode 94 = 7 % ^
84
+ \TMP@EnsureCode 95 = 8 % _
85
+ %% Constants --------------------------------------------------------
86
+ \newcount \c@taburow \def\thetaburow {\number\c@taburow}
87
+ \newcount \tabu@nbcols
88
+ \newcount \tabu@cnt
89
+ \newcount \tabu@Xcol
90
+ \let\tabu@start \@tempcnta
91
+ \let\tabu@stop \@tempcntb
92
+ \newcount \tabu@alloc \tabu@alloc=\m@ne
93
+ \newcount \tabu@nested
94
+ \def\tabu@alloc@{\global\advance\tabu@alloc \@ne \tabu@nested\tabu@alloc}
95
+ \newdimen \tabu@target
96
+ \newdimen \tabu@spreadtarget
97
+ \newdimen \tabu@naturalX
98
+ \newdimen \tabucolX
99
+ \let\tabu@DELTA \@tempdimc
100
+ \let\tabu@thick \@tempdima
101
+ \let\tabu@on \@tempdimb
102
+ \let\tabu@off \@tempdimc
103
+ \newdimen \tabu@Xsum
104
+ \newdimen \extrarowdepth
105
+ \newdimen \abovetabulinesep
106
+ \newdimen \belowtabulinesep
107
+ \newdimen \tabustrutrule \tabustrutrule \z@
108
+ \newtoks \tabu@thebody
109
+ \newtoks \tabu@footnotes
110
+ \newsavebox \tabu@box
111
+ \newsavebox \tabu@arstrutbox
112
+ \newsavebox \tabu@hleads
113
+ \newsavebox \tabu@vleads
114
+ \newif \iftabu@colortbl
115
+ \newif \iftabu@siunitx
116
+ \newif \iftabu@measuring
117
+ \newif \iftabu@spread
118
+ \newif \iftabu@negcoef
119
+ \newif \iftabu@everyrow
120
+ \def\tabu@everyrowtrue {\global\let\iftabu@everyrow \iftrue}
121
+ \def\tabu@everyrowfalse{\global\let\iftabu@everyrow \iffalse}
122
+ \newif \iftabu@long
123
+ \newif \iftabuscantokens
124
+ \def\tabu@rescan {\tabu@verbatim \scantokens }
125
+ %% Utilities (for internal usage) -----------------------------------
126
+ \def\tabu@gobblespace #1 {#1}
127
+ \def\tabu@gobbletoken #1#2{#1}
128
+ \def\tabu@gobbleX{\futurelet\@let@token \tabu@gobblex}
129
+ \def\tabu@gobblex{\if ^^J\noexpand\@let@token \expandafter\@gobble
130
+ \else\ifx \@sptoken\@let@token
131
+ \expandafter\tabu@gobblespace\expandafter\tabu@gobbleX
132
+ \fi\fi
133
+ }% \tabu@gobblex
134
+ \def\tabu@X{^^J}
135
+ {\obeyspaces
136
+ \global\let\tabu@spxiii= % saves an active space (for \ifx)
137
+ \gdef\tabu@@spxiii{ }}
138
+ \def\tabu@ifenvir {% only for \multicolumn
139
+ \expandafter\tabu@if@nvir\csname\@currenvir\endcsname
140
+ }% \tabu@ifenvir
141
+ \def\tabu@if@nvir #1{\csname @\ifx\tabu#1first\else
142
+ \ifx\longtabu#1first\else
143
+ second\fi\fi oftwo\endcsname
144
+ }% \tabu@ifenvir
145
+ \def\tabu@modulo #1#2{\numexpr\ifnum\numexpr#1=\z@ 0\else #1-(#1-(#2-1)/2)/(#2)*(#2)\fi}
146
+ {\catcode`\&=3
147
+ \gdef\tabu@strtrim #1{% #1 = control sequence to trim
148
+ \ifodd 1\ifx #1\@empty \else \ifx #1\space \else 0\fi \fi
149
+ \let\tabu@c@l@r \@empty \let#1\@empty
150
+ \else \expandafter \tabu@trimspaces #1&#1\@nnil
151
+ \fi
152
+ }% \tabu@strtrim
153
+ \gdef\tabu@trimspaces #1&#2\@nnil{\let\tabu@c@l@r=#2\tabu@firstspace .#1& &#2}%
154
+ \gdef\tabu@firstspace #1#2#3 &{\tabu@lastspace #2#3&}
155
+ \gdef\tabu@lastspace #1&#2&#3{\def #3{#1}%
156
+ \ifx #3\tabu@c@l@r \def\tabu@c@l@r{\protect\color{#1}}\expandafter\remove@to@nnil \fi
157
+ \tabu@trimspaces #1&#3\@nnil}
158
+ }% \catcode
159
+ \def\tabu@sanitizearg #1#2{{%
160
+ \csname \ifcsname if@safe@actives\endcsname % <babel>
161
+ @safe@activestrue\else
162
+ relax\fi \endcsname
163
+ \edef#2{#1}\tabu@strtrim#2\@onelevel@sanitize#2%
164
+ \expandafter}\expandafter\def\expandafter#2\expandafter{#2}%
165
+ }% \tabu@sanitizearg
166
+ \def\tabu@textbar #1{\begingroup \endlinechar\m@ne \scantokens{\def\:{|}}%
167
+ \expandafter\endgroup \expandafter#1\:% !!! semi simple group !!!
168
+ }% \tabu@textbar
169
+ \def\tabu@everyrow@bgroup{\iftabu@everyrow \begingroup \else \noalign{\ifnum0=`}\fi \fi}
170
+ \def\tabu@everyrow@egroup{%
171
+ \iftabu@everyrow \expandafter \endgroup \the\toks@
172
+ \else \ifnum0=`{\fi}%
173
+ \fi
174
+ }% \tabu@everyrow@egroup
175
+ \def\tabu@arstrut {\global\setbox\@arstrutbox \hbox{\vrule
176
+ height \arraystretch \dimexpr\ht\strutbox+\extrarowheight
177
+ depth \arraystretch \dimexpr\dp\strutbox+\extrarowdepth
178
+ width \z@}%
179
+ }% \tabu@arstrut
180
+ \def\tabu@rearstrut {%
181
+ \@tempdima \arraystretch\dimexpr\ht\strutbox+\extrarowheight \relax
182
+ \@tempdimb \arraystretch\dimexpr\dp\strutbox+\extrarowdepth \relax
183
+ \ifodd 1\ifdim \ht\@arstrutbox=\@tempdima
184
+ \ifdim \dp\@arstrutbox=\@tempdimb 0 \fi\fi
185
+ \tabu@mkarstrut
186
+ \fi
187
+ }% \tabu@rearstrut
188
+ \def\tabu@@DBG #1{\ifdim\tabustrutrule>\z@ \color{#1}\fi}
189
+ \def\tabu@DBG@arstrut {\global\setbox\@arstrutbox
190
+ \hbox to\z@{\hbox to\z@{\hss
191
+ {\tabu@DBG{cyan}\vrule
192
+ height \arraystretch \dimexpr\ht\strutbox+\extrarowheight
193
+ depth \z@
194
+ width \tabustrutrule}\kern-\tabustrutrule
195
+ {\tabu@DBG{pink}\vrule
196
+ height \z@
197
+ depth \arraystretch \dimexpr\dp\strutbox+\extrarowdepth
198
+ width \tabustrutrule}}}%
199
+ }% \tabu@DBG@arstrut
200
+ \def\tabu@save@decl{\toks\count@ \expandafter{\the\toks\expandafter\count@
201
+ \@nextchar}}%
202
+ \def\tabu@savedecl{\ifcat$\d@llarend\else
203
+ \let\save@decl \tabu@save@decl \fi % no inversion of tokens in text mode
204
+ }% \tabu@savedecl
205
+ \def\tabu@finalstrut #1{\unskip\ifhmode\nobreak\fi\vrule height\z@ depth\z@ width\z@}
206
+ \newcommand*\tabuDisableCommands {\g@addto@macro\tabu@trialh@@k }
207
+ \let\tabu@trialh@@k \@empty
208
+ \def\tabu@nowrite #1#{{\afterassignment}\toks@}
209
+ \let\tabu@write\write
210
+ \let\tabu@immediate\immediate
211
+ \def\tabu@WRITE{\begingroup
212
+ \def\immediate\write{\aftergroup\endgroup
213
+ \tabu@immediate\tabu@write}%
214
+ }% \tabu@WRITE
215
+ \expandafter\def\expandafter\tabu@GenericError\expandafter{%
216
+ \expandafter\tabu@WRITE\GenericError}
217
+ \def\tabu@warn{\tabu@WRITE\PackageWarning{tabu}}
218
+ \def\tabu@noxfootnote [#1]{\@gobble}
219
+ \def\tabu@nocolor #1#{\@gobble}
220
+ \newcommand*\tabu@norowcolor[2][]{}
221
+ \def\tabu@maybesiunitx #1{\def\tabu@temp{#1}%
222
+ \futurelet\@let@token \tabu@m@ybesiunitx}
223
+ \def\tabu@m@ybesiunitx #1{\def\tabu@m@ybesiunitx {%
224
+ \ifx #1\@let@token \let\tabu@cellleft \@empty \let\tabu@cellright \@empty \fi
225
+ \tabu@temp}% \tabu@m@ybesiunitx
226
+ }\expandafter\tabu@m@ybesiunitx \csname siunitx_table_collect_begin:Nn\endcsname
227
+ \def\tabu@celllalign@def #1{\def\tabu@celllalign{\tabu@maybesiunitx{#1}}}%
228
+ %% Fixed vertical spacing adjustment: \extrarowsep ------------------
229
+ \newcommand*\extrarowsep{\edef\tabu@C@extra{\the\numexpr\tabu@C@extra+1}%
230
+ \iftabu@everyrow \aftergroup\tabu@Gextra
231
+ \else \aftergroup\tabu@n@Gextra
232
+ \fi
233
+ \@ifnextchar={\tabu@gobbletoken\tabu@extra} \tabu@extra
234
+ }% \extrarowsep
235
+ \def\tabu@extra {\@ifnextchar_%
236
+ {\tabu@gobbletoken{\tabu@setextra\extrarowheight \extrarowdepth}}
237
+ {\ifx ^\@let@token \def\tabu@temp{%
238
+ \tabu@gobbletoken{\tabu@setextra\extrarowdepth \extrarowheight}}%
239
+ \else \let\tabu@temp \@empty
240
+ \afterassignment \tabu@setextrasep \extrarowdepth
241
+ \fi \tabu@temp}%
242
+ }% \tabu@extra
243
+ \def\tabu@setextra #1#2{\def\tabu@temp{\tabu@extr@#1#2}\afterassignment\tabu@temp#2}
244
+ \def\tabu@extr@ #1#2{\@ifnextchar^%
245
+ {\tabu@gobbletoken{\tabu@setextra\extrarowdepth \extrarowheight}}
246
+ {\ifx _\@let@token \def\tabu@temp{%
247
+ \tabu@gobbletoken{\tabu@setextra\extrarowheight \extrarowdepth}}%
248
+ \else \let\tabu@temp \@empty
249
+ \tabu@Gsave \tabu@G@extra \tabu@C@extra \extrarowheight \extrarowdepth
250
+ \fi \tabu@temp}%
251
+ }% \tabu@extr@
252
+ \def\tabu@setextrasep {\extrarowheight=\extrarowdepth
253
+ \tabu@Gsave \tabu@G@extra \tabu@C@extra \extrarowheight \extrarowdepth
254
+ }% \tabu@setextrasep
255
+ \def\tabu@Gextra{\ifx \tabu@G@extra\@empty \else {\tabu@Rextra}\fi}
256
+ \def\tabu@n@Gextra{\ifx \tabu@G@extra\@empty \else \noalign{\tabu@Rextra}\fi}
257
+ \def\tabu@Rextra{\tabu@Grestore \tabu@G@extra \tabu@C@extra}
258
+ \let\tabu@C@extra \z@
259
+ \let\tabu@G@extra \@empty
260
+ %% Dynamic vertical spacing adjustment: \tabulinesep ----------------
261
+ \newcommand*\tabulinesep{\edef\tabu@C@linesep{\the\numexpr\tabu@C@linesep+1}%
262
+ \iftabu@everyrow \aftergroup\tabu@Glinesep
263
+ \else \aftergroup\tabu@n@Glinesep
264
+ \fi
265
+ \@ifnextchar={\tabu@gobbletoken\tabu@linesep} \tabu@linesep
266
+ }% \tabulinesep
267
+ \def\tabu@linesep {\@ifnextchar_%
268
+ {\tabu@gobbletoken{\tabu@setsep\abovetabulinesep \belowtabulinesep}}
269
+ {\ifx ^\@let@token \def\tabu@temp{%
270
+ \tabu@gobbletoken{\tabu@setsep\belowtabulinesep \abovetabulinesep}}%
271
+ \else \let\tabu@temp \@empty
272
+ \afterassignment \tabu@setlinesep \abovetabulinesep
273
+ \fi \tabu@temp}%
274
+ }% \tabu@linesep
275
+ \def\tabu@setsep #1#2{\def\tabu@temp{\tabu@sets@p#1#2}\afterassignment\tabu@temp#2}
276
+ \def\tabu@sets@p #1#2{\@ifnextchar^%
277
+ {\tabu@gobbletoken{\tabu@setsep\belowtabulinesep \abovetabulinesep}}
278
+ {\ifx _\@let@token \def\tabu@temp{%
279
+ \tabu@gobbletoken{\tabu@setsep\abovetabulinesep \belowtabulinesep}}%
280
+ \else \let\tabu@temp \@empty
281
+ \tabu@Gsave \tabu@G@linesep \tabu@C@linesep \abovetabulinesep \belowtabulinesep
282
+ \fi \tabu@temp}%
283
+ }% \tabu@sets@p
284
+ \def\tabu@setlinesep {\belowtabulinesep=\abovetabulinesep
285
+ \tabu@Gsave \tabu@G@linesep \tabu@C@linesep \abovetabulinesep \belowtabulinesep
286
+ }% \tabu@setlinesep
287
+ \def\tabu@Glinesep{\ifx \tabu@G@linesep\@empty \else {\tabu@Rlinesep}\fi}
288
+ \def\tabu@n@Glinesep{\ifx \tabu@G@linesep\@empty \else \noalign{\tabu@Rlinesep}\fi}
289
+ \def\tabu@Rlinesep{\tabu@Grestore \tabu@G@linesep \tabu@C@linesep}
290
+ \let\tabu@C@linesep \z@
291
+ \let\tabu@G@linesep \@empty
292
+ %% \global\extrarowsep and \global\tabulinesep -------------------
293
+ \def\tabu@Gsave #1#2#3#4{\xdef#1{#1%
294
+ \toks#2{\toks\the\currentgrouplevel{\global#3\the#3\global#4\the#4}}}%
295
+ }% \tabu@Gsave
296
+ \def\tabu@Grestore#1#2{%
297
+ \toks#2{}#1\toks\currentgrouplevel\expandafter{\expandafter}\the\toks#2\relax
298
+ \ifcat$\the\toks\currentgrouplevel$\else
299
+ \global\let#1\@empty \global\let#2\z@
300
+ \the\toks\currentgrouplevel
301
+ \fi
302
+ }% \tabu@Grestore
303
+ %% Setting code for every row ---------------------------------------
304
+ \newcommand*\everyrow{\tabu@everyrow@bgroup
305
+ \tabu@start \z@ \tabu@stop \z@ \tabu@evrstartstop
306
+ }% \everyrow
307
+ \def\tabu@evrstartstop {\@ifnextchar^%
308
+ {\afterassignment \tabu@evrstartstop \tabu@stop=}%
309
+ {\ifx ^\@let@token
310
+ \afterassignment\tabu@evrstartstop \tabu@start=%
311
+ \else \afterassignment\tabu@everyr@w \toks@
312
+ \fi}%
313
+ }% \tabu@evrstartstop
314
+ \def\tabu@everyr@w {%
315
+ \xdef\tabu@everyrow{%
316
+ \noexpand\tabu@everyrowfalse
317
+ \let\noalign \relax
318
+ \noexpand\tabu@rowfontreset
319
+ \iftabu@colortbl \noexpand\tabu@rc@ \fi % \taburowcolors
320
+ \let\noexpand\tabu@docline \noexpand\tabu@docline@evr
321
+ \the\toks@
322
+ \noexpand\tabu@evrh@@k
323
+ \noexpand\tabu@rearstrut
324
+ \global\advance\c@taburow \@ne}%
325
+ \iftabu@everyrow \toks@\expandafter
326
+ {\expandafter\def\expandafter\tabu@evr@L\expandafter{\the\toks@}\ignorespaces}%
327
+ \else \xdef\tabu@evr@G{\the\toks@}%
328
+ \fi
329
+ \tabu@everyrow@egroup
330
+ }% \tabu@everyr@w
331
+ \def\tabu@evr {\def\tabu@evrh@@k} % for internal use only
332
+ \tabu@evr{}
333
+ %% line style and leaders -------------------------------------------
334
+ \newcommand*\newtabulinestyle [1]{%
335
+ {\@for \@tempa :=#1\do{\expandafter\tabu@newlinestyle \@tempa==\@nil}}%
336
+ }% \newtabulinestyle
337
+ \def\tabu@newlinestyle #1=#2=#3\@nil{\tabu@getline {#2}%
338
+ \tabu@sanitizearg {#1}\@tempa
339
+ \ifodd 1\ifx \@tempa\@empty \ifdefined\tabu@linestyle@ 0 \fi\fi
340
+ \global\expandafter\let
341
+ \csname tabu@linestyle@\@tempa \endcsname =\tabu@thestyle \fi
342
+ }% \tabu@newlinestyle
343
+ \newcommand*\tabulinestyle [1]{\tabu@everyrow@bgroup \tabu@getline{#1}%
344
+ \iftabu@everyrow
345
+ \toks@\expandafter{\expandafter \def \expandafter
346
+ \tabu@ls@L\expandafter{\tabu@thestyle}\ignorespaces}%
347
+ \gdef\tabu@ls@{\tabu@ls@L}%
348
+ \else
349
+ \global\let\tabu@ls@G \tabu@thestyle
350
+ \gdef\tabu@ls@{\tabu@ls@G}%
351
+ \fi
352
+ \tabu@everyrow@egroup
353
+ }% \tabulinestyle
354
+ \newcommand*\taburulecolor{\tabu@everyrow@bgroup \tabu@textbar \tabu@rulecolor}
355
+ \def\tabu@rulecolor #1{\toks@{}%
356
+ \def\tabu@temp #1##1#1{\tabu@ruledrsc{##1}}\@ifnextchar #1%
357
+ \tabu@temp
358
+ \tabu@rulearc
359
+ }% \tabu@rulecolor
360
+ \def\tabu@ruledrsc #1{\edef\tabu@temp{#1}\tabu@strtrim\tabu@temp
361
+ \ifx \tabu@temp\@empty \def\tabu@temp{\tabu@rule@drsc@ {}{}}%
362
+ \else \edef\tabu@temp{\noexpand\tabu@rule@drsc@ {}{\tabu@temp}}%
363
+ \fi
364
+ \tabu@temp
365
+ }% \tabu@ruledrsc@
366
+ \def\tabu@ruledrsc@ #1#{\tabu@rule@drsc@ {#1}}
367
+ \def\tabu@rule@drsc@ #1#2{%
368
+ \iftabu@everyrow
369
+ \ifx \\#1#2\\\toks@{\let\CT@drsc@ \relax}%
370
+ \else \toks@{\def\CT@drsc@{\color #1{#2}}}%
371
+ \fi
372
+ \else
373
+ \ifx \\#1#2\\\global\let\CT@drsc@ \relax
374
+ \else \gdef\CT@drsc@{\color #1{#2}}%
375
+ \fi
376
+ \fi
377
+ \tabu@rulearc
378
+ }% \tabu@rule@drsc@
379
+ \def\tabu@rulearc #1#{\tabu@rule@arc@ {#1}}
380
+ \def\tabu@rule@arc@ #1#2{%
381
+ \iftabu@everyrow
382
+ \ifx \\#1#2\\\toks@\expandafter{\the\toks@ \def\CT@arc@{}}%
383
+ \else \toks@\expandafter{\the\toks@ \def\CT@arc@{\color #1{#2}}}%
384
+ \fi
385
+ \toks@\expandafter{\the\toks@
386
+ \let\tabu@arc@L \CT@arc@
387
+ \let\tabu@drsc@L \CT@drsc@
388
+ \ignorespaces}%
389
+ \else
390
+ \ifx \\#1#2\\\gdef\CT@arc@{}%
391
+ \else \gdef\CT@arc@{\color #1{#2}}%
392
+ \fi
393
+ \global\let\tabu@arc@G \CT@arc@
394
+ \global\let\tabu@drsc@G \CT@drsc@
395
+ \fi
396
+ \tabu@everyrow@egroup
397
+ }% \tabu@rule@arc@
398
+ \def\taburowcolors {\tabu@everyrow@bgroup \@testopt \tabu@rowcolors 1}
399
+ \def\tabu@rowcolors [#1]#2#{\tabu@rowc@lors{#1}{#2}}
400
+ \def\tabu@rowc@lors #1#2#3{%
401
+ \toks@{}\@defaultunits \count@ =\number0#2\relax \@nnil
402
+ \@defaultunits \tabu@start =\number0#1\relax \@nnil
403
+ \ifnum \count@<\tw@ \count@=\tw@ \fi
404
+ \advance\tabu@start \m@ne
405
+ \ifnum \tabu@start<\z@ \tabu@start \z@ \fi
406
+ \tabu@rowcolorseries #3\in@..\in@ \@nnil
407
+ }% \tabu@rowcolors
408
+ \def\tabu@rowcolorseries #1..#2\in@ #3\@nnil {%
409
+ \ifx \in@#1\relax
410
+ \iftabu@everyrow \toks@{\def\tabu@rc@{}\let\tabu@rc@L \tabu@rc@}%
411
+ \else \gdef\tabu@rc@{}\global\let\tabu@rc@G \tabu@rc@
412
+ \fi
413
+ \else
414
+ \ifx \\#2\\\tabu@rowcolorserieserror \fi
415
+ \tabu@sanitizearg{#1}\tabu@temp
416
+ \tabu@sanitizearg{#2}\@tempa
417
+ \advance\count@ \m@ne
418
+ \iftabu@everyrow
419
+ \def\tabu@rc@ ##1##2##3##4{\def\tabu@rc@{%
420
+ \ifnum ##2=\c@taburow
421
+ \definecolorseries{tabu@rcseries@\the\tabu@nested}{rgb}{last}{##3}{##4}\fi
422
+ \ifnum \c@taburow<##2 \else
423
+ \ifnum \tabu@modulo {\c@taburow-##2}{##1+1}=\z@
424
+ \resetcolorseries[{##1}]{tabu@rcseries@\the\tabu@nested}\fi
425
+ \xglobal\colorlet{tabu@rc@\the\tabu@nested}{tabu@rcseries@\the\tabu@nested!!+}%
426
+ \rowcolor{tabu@rc@\the\tabu@nested}\fi}%
427
+ }\edef\x{\noexpand\tabu@rc@ {\the\count@}
428
+ {\the\tabu@start}
429
+ {\tabu@temp}
430
+ {\@tempa}%
431
+ }\x
432
+ \toks@\expandafter{\expandafter\def\expandafter\tabu@rc@\expandafter{\tabu@rc@}}%
433
+ \toks@\expandafter{\the\toks@ \let\tabu@rc@L \tabu@rc@ \ignorespaces}%
434
+ \else % inside \noalign
435
+ \definecolorseries{tabu@rcseries@\the\tabu@nested}{rgb}{last}{\tabu@temp}{\@tempa}%
436
+ \expandafter\resetcolorseries\expandafter[\the\count@]{tabu@rcseries@\the\tabu@nested}%
437
+ \xglobal\colorlet{tabu@rc@\the\tabu@nested}{tabu@rcseries@\the\tabu@nested!!+}%
438
+ \let\noalign \relax \rowcolor{tabu@rc@\the\tabu@nested}%
439
+ \def\tabu@rc@ ##1##2{\gdef\tabu@rc@{%
440
+ \ifnum \tabu@modulo {\c@taburow-##2}{##1+1}=\@ne
441
+ \resetcolorseries[{##1}]{tabu@rcseries@\the\tabu@nested}\fi
442
+ \xglobal\colorlet{tabu@rc@\the\tabu@nested}{tabu@rcseries@\the\tabu@nested!!+}%
443
+ \rowcolor{tabu@rc@\the\tabu@nested}}%
444
+ }\edef\x{\noexpand\tabu@rc@{\the\count@}{\the\c@taburow}}\x
445
+ \global\let\tabu@rc@G \tabu@rc@
446
+ \fi
447
+ \fi
448
+ \tabu@everyrow@egroup
449
+ }% \tabu@rowcolorseries
450
+ \tabuDisableCommands {\let\tabu@rc@ \@empty }
451
+ \def\tabu@rowcolorserieserror {\PackageError{tabu}
452
+ {Invalid syntax for \string\taburowcolors
453
+ \MessageBreak Please look at the documentation!}\@ehd
454
+ }% \tabu@rowcolorserieserror
455
+ \newcommand*\tabureset {%
456
+ \tabulinesep=\z@ \extrarowsep=\z@ \extratabsurround=\z@
457
+ \tabulinestyle{}\everyrow{}\taburulecolor||{}\taburowcolors{}%
458
+ }% \tabureset
459
+ %% Parsing the line styles ------------------------------------------
460
+ \def\tabu@getline #1{\begingroup
461
+ \csname \ifcsname if@safe@actives\endcsname % <babel>
462
+ @safe@activestrue\else
463
+ relax\fi \endcsname
464
+ \edef\tabu@temp{#1}\tabu@sanitizearg{#1}\@tempa
465
+ \let\tabu@thestyle \relax
466
+ \ifcsname tabu@linestyle@\@tempa \endcsname
467
+ \edef\tabu@thestyle{\endgroup
468
+ \def\tabu@thestyle{\expandafter\noexpand
469
+ \csname tabu@linestyle@\@tempa\endcsname}%
470
+ }\tabu@thestyle
471
+ \else \expandafter\tabu@definestyle \tabu@temp \@nil
472
+ \fi
473
+ }% \tabu@getline
474
+ \def\tabu@definestyle #1#2\@nil {\endlinechar \m@ne \makeatletter
475
+ \tabu@thick \maxdimen \tabu@on \maxdimen \tabu@off \maxdimen
476
+ \let\tabu@c@lon \@undefined \let\tabu@c@loff \@undefined
477
+ \ifodd 1\ifcat .#1\else\ifcat\relax #1\else 0\fi\fi % catcode 12 or non expandable cs
478
+ \def\tabu@temp{\tabu@getparam{thick}}%
479
+ \else \def\tabu@temp{\tabu@getparam{thick}\maxdimen}%
480
+ \fi
481
+ {%
482
+ \let\tabu@ \relax
483
+ \def\:{\obeyspaces \tabu@oXIII \tabu@commaXIII \edef\:}% (space active \: happy ;-))
484
+ \scantokens{\:{\tabu@temp #1#2 \tabu@\tabu@}}%
485
+ \expandafter}\expandafter
486
+ \def\expandafter\:\expandafter{\:}% line spec rewritten now ;-)
487
+ \def\;{\def\:}%
488
+ \scantokens\expandafter{\expandafter\;\expandafter{\:}}% space is now inactive (catcode 10)
489
+ \let\tabu@ \tabu@getcolor \:% all arguments are ready now ;-)
490
+ \ifdefined\tabu@c@lon \else \let\tabu@c@lon\@empty \fi
491
+ \ifx \tabu@c@lon\@empty \def\tabu@c@lon{\CT@arc@}\fi
492
+ \ifdefined\tabu@c@loff \else \let\tabu@c@loff \@empty \fi
493
+ \ifdim \tabu@on=\maxdimen \ifdim \tabu@off<\maxdimen
494
+ \tabu@on \tabulineon \fi\fi
495
+ \ifdim \tabu@off=\maxdimen \ifdim \tabu@on<\maxdimen
496
+ \tabu@off \tabulineoff \fi\fi
497
+ \ifodd 1\ifdim \tabu@off=\maxdimen \ifdim \tabu@on=\maxdimen 0 \fi\fi
498
+ \in@true % <leaders>
499
+ \else \in@false % <rule>
500
+ \fi
501
+ \ifdim\tabu@thick=\maxdimen \def\tabu@thick{\arrayrulewidth}%
502
+ \else \edef\tabu@thick{\the\tabu@thick}%
503
+ \fi
504
+ \edef \tabu@thestyle ##1##2{\endgroup
505
+ \def\tabu@thestyle{%
506
+ \ifin@ \noexpand\tabu@leadersstyle {\tabu@thick}
507
+ {\the\tabu@on}{##1}
508
+ {\the\tabu@off}{##2}%
509
+ \else \noexpand\tabu@rulesstyle
510
+ {##1\vrule width \tabu@thick}%
511
+ {##1\leaders \hrule height \tabu@thick \hfil}%
512
+ \fi}%
513
+ }\expandafter \expandafter
514
+ \expandafter \tabu@thestyle \expandafter
515
+ \expandafter \expandafter
516
+ {\expandafter\tabu@c@lon\expandafter}\expandafter{\tabu@c@loff}%
517
+ }% \tabu@definestyle
518
+ {\catcode`\O=\active \lccode`\O=`\o \catcode`\,=\active
519
+ \lowercase{\gdef\tabu@oXIII {\catcode`\o=\active \let O=\tabu@oxiii}}
520
+ \gdef\tabu@commaXIII {\catcode`\,=\active \let ,=\space}
521
+ }% \catcode
522
+ \def\tabu@oxiii #1{%
523
+ \ifcase \ifx n#1\z@ \else
524
+ \ifx f#1\@ne\else
525
+ \tw@ \fi\fi
526
+ \expandafter\tabu@onxiii
527
+ \or \expandafter\tabu@ofxiii
528
+ \else o%
529
+ \fi#1}%
530
+ \def\tabu@onxiii #1#2{%
531
+ \ifcase \ifx !#2\tw@ \else
532
+ \ifcat.\noexpand#2\z@ \else
533
+ \ifx \tabu@spxiii#2\@ne\else
534
+ \tw@ \fi\fi\fi
535
+ \tabu@getparam{on}#2\expandafter\@gobble
536
+ \or \expandafter\tabu@onxiii % (space is active)
537
+ \else o\expandafter\@firstofone
538
+ \fi{#1#2}}%
539
+ \def\tabu@ofxiii #1#2{%
540
+ \ifx #2f\expandafter\tabu@offxiii
541
+ \else o\expandafter\@firstofone
542
+ \fi{#1#2}}
543
+ \def\tabu@offxiii #1#2{%
544
+ \ifcase \ifx !#2\tw@ \else
545
+ \ifcat.\noexpand#2\z@ \else
546
+ \ifx\tabu@spxiii#2\@ne \else
547
+ \tw@ \fi\fi\fi
548
+ \tabu@getparam{off}#2\expandafter\@gobble
549
+ \or \expandafter\tabu@offxiii % (space is active)
550
+ \else o\expandafter\@firstofone
551
+ \fi{#1#2}}
552
+ \def\tabu@getparam #1{\tabu@ \csname tabu@#1\endcsname=}
553
+ \def\tabu@getcolor #1{% \tabu@ <- \tabu@getcolor after \edef
554
+ \ifx \tabu@#1\else % no more spec
555
+ \let\tabu@theparam=#1\afterassignment \tabu@getc@l@r #1\fi
556
+ }% \tabu@getcolor
557
+ \def\tabu@getc@l@r #1\tabu@ {%
558
+ \def\tabu@temp{#1}\tabu@strtrim \tabu@temp
559
+ \ifx \tabu@temp\@empty
560
+ \else%\ifcsname \string\color@\tabu@temp \endcsname % if the color exists
561
+ \ifx \tabu@theparam \tabu@off \let\tabu@c@loff \tabu@c@l@r
562
+ \else \let\tabu@c@lon \tabu@c@l@r
563
+ \fi
564
+ %\else \tabu@warncolour{\tabu@temp}%
565
+ \fi%\fi
566
+ \tabu@ % next spec
567
+ }% \tabu@getc@l@r
568
+ \def\tabu@warncolour #1{\PackageWarning{tabu}
569
+ {Color #1 is not defined. Default color used}%
570
+ }% \tabu@warncolour
571
+ \def\tabu@leadersstyle #1#2#3#4#5{\def\tabu@leaders{{#1}{#2}{#3}{#4}{#5}}%
572
+ \ifx \tabu@leaders\tabu@leaders@G \else
573
+ \tabu@LEADERS{#1}{#2}{#3}{#4}{#5}\fi
574
+ }% \tabu@leadersstyle
575
+ \def\tabu@rulesstyle #1#2{\let\tabu@leaders \@undefined
576
+ \gdef\tabu@thevrule{#1}\gdef\tabu@thehrule{#2}%
577
+ }% \tabu@rulesstyle
578
+ %% The leaders boxes ------------------------------------------------
579
+ \def\tabu@LEADERS #1#2#3#4#5{%% width, dash, dash color, gap, gap color
580
+ {\let\color \tabu@color % => during trials -> \color = \tabu@nocolor
581
+ {% % but the leaders boxes should have colors !
582
+ \def\@therule{\vrule}\def\@thick{height}\def\@length{width}%
583
+ \def\@box{\hbox}\def\@unbox{\unhbox}\def\@elt{\wd}%
584
+ \def\@skip{\hskip}\def\@ss{\hss}\def\tabu@leads{\tabu@hleads}%
585
+ \tabu@l@@d@rs {#1}{#2}{#3}{#4}{#5}%
586
+ \global\let\tabu@thehleaders \tabu@theleaders
587
+ }%
588
+ {%
589
+ \def\@therule{\hrule}\def\@thick{width}\def\@length{height}%
590
+ \def\@box{\vbox}\def\@unbox{\unvbox}\def\@elt{\ht}%
591
+ \def\@skip{\vskip}\def\@ss{\vss}\def\tabu@leads{\tabu@vleads}%
592
+ \tabu@l@@d@rs {#1}{#2}{#3}{#4}{#5}%
593
+ \global\let\tabu@thevleaders \tabu@theleaders
594
+ }%
595
+ \gdef\tabu@leaders@G{{#1}{#2}{#3}{#4}{#5}}%
596
+ }%
597
+ }% \tabu@LEADERS
598
+ \def\tabu@therule #1#2{\@therule \@thick#1\@length\dimexpr#2/2 \@depth\z@}
599
+ \def\tabu@l@@d@rs #1#2#3#4#5{%% width, dash, dash color, gap, gap color
600
+ \global\setbox \tabu@leads=\@box{%
601
+ {#3\tabu@therule{#1}{#2}}%
602
+ \ifx\\#5\\\@skip#4\else{#5\tabu@therule{#1}{#4*2}}\fi
603
+ {#3\tabu@therule{#1}{#2}}}%
604
+ \global\setbox\tabu@leads=\@box to\@elt\tabu@leads{\@ss
605
+ {#3\tabu@therule{#1}{#2}}\@unbox\tabu@leads}%
606
+ \edef\tabu@theleaders ##1{\def\noexpand\tabu@theleaders {%
607
+ {##1\tabu@therule{#1}{#2}}%
608
+ \xleaders \copy\tabu@leads \@ss
609
+ \tabu@therule{0pt}{-#2}{##1\tabu@therule{#1}{#2}}}%
610
+ }\tabu@theleaders{#3}%
611
+ }% \tabu@l@@d@rs
612
+ %% \tabu \endtabu \tabu* \longtabu \endlongtabu \longtabu* ----------
613
+ \newcommand*\tabu {\tabu@longfalse
614
+ \ifmmode \def\tabu@ {\array}\def\endtabu {\endarray}%
615
+ \else \def\tabu@ {\tabu@tabular}\def\endtabu {\endtabular}\fi
616
+ \expandafter\let\csname tabu*\endcsname \tabu
617
+ \expandafter\def\csname endtabu*\endcsname{\endtabu}%
618
+ \tabu@spreadfalse \tabu@negcoeffalse \tabu@settarget
619
+ }% {tabu}
620
+ \let\tabu@tabular \tabular % <For LyX: some users redefine \tabular...>
621
+ \expandafter\def\csname tabu*\endcsname{\tabuscantokenstrue \tabu}
622
+ \newcommand*\longtabu {\tabu@longtrue
623
+ \ifmmode\PackageError{tabu}{longtabu not allowed in math mode}\fi
624
+ \def\tabu@{\longtable}\def\endlongtabu{\endlongtable}%
625
+ \LTchunksize=\@M
626
+ \expandafter\let\csname tabu*\endcsname \tabu
627
+ \expandafter\def\csname endlongtabu*\endcsname{\endlongtabu}%
628
+ \let\LT@startpbox \tabu@LT@startpbox % \everypar{ array struts }
629
+ \tabu@spreadfalse \tabu@negcoeffalse \tabu@settarget
630
+ }% {longtabu}
631
+ \expandafter\def\csname longtabu*\endcsname{\tabuscantokenstrue \longtabu}
632
+ \def\tabu@nolongtabu{\PackageError{tabu}
633
+ {longtabu requires the longtable package}\@ehd}
634
+ %% Read the target and then : \tabular or \@array ------------------
635
+ \def\tabu@settarget {\futurelet\@let@token \tabu@sett@rget }
636
+ \def\tabu@sett@rget {\tabu@target \z@
637
+ \ifcase \ifx \bgroup\@let@token \z@ \else
638
+ \ifx \@sptoken\@let@token \@ne \else
639
+ \if t\@let@token \tw@ \else
640
+ \if s\@let@token \thr@@\else
641
+ \z@\fi\fi\fi\fi
642
+ \expandafter\tabu@begin
643
+ \or \expandafter\tabu@gobblespace\expandafter\tabu@settarget
644
+ \or \expandafter\tabu@to
645
+ \or \expandafter\tabu@spread
646
+ \fi
647
+ }% \tabu@sett@rget
648
+ \def\tabu@to to{\def\tabu@halignto{to}\tabu@gettarget}
649
+ \def\tabu@spread spread{\tabu@spreadtrue\def\tabu@halignto{spread}\tabu@gettarget}
650
+ \def\tabu@gettarget {\afterassignment\tabu@linegoaltarget \tabu@target }
651
+ \def\tabu@linegoaltarget {\futurelet\tabu@temp \tabu@linegoalt@rget }
652
+ \def\tabu@linegoalt@rget {%
653
+ \ifx \tabu@temp\LNGL@setlinegoal
654
+ \LNGL@setlinegoal \expandafter \@firstoftwo \fi % @gobbles \LNGL@setlinegoal
655
+ \tabu@begin
656
+ }% \tabu@linegoalt@rget
657
+ \def\tabu@begin #1#{%
658
+ \iftabu@measuring \expandafter\tabu@nestedmeasure \fi
659
+ \ifdim \tabu@target=\z@ \let\tabu@halignto \@empty
660
+ \else \edef\tabu@halignto{\tabu@halignto\the\tabu@target}%
661
+ \fi
662
+ \@testopt \tabu@tabu@ \tabu@aligndefault #1\@nil
663
+ }% \tabu@begin
664
+ \long\def\tabu@tabu@ [#1]#2\@nil #3{\tabu@setup
665
+ \def\tabu@align {#1}\def\tabu@savedpream{\NC@find #3}%
666
+ \tabu@ [\tabu@align ]#2{#3\tabu@rewritefirst }%
667
+ }% \tabu@tabu@
668
+ \def\tabu@nestedmeasure {%
669
+ \ifodd 1\iftabu@spread \else \ifdim\tabu@target=\z@ \else 0 \fi\fi\relax
670
+ \tabu@spreadtrue
671
+ \else \begingroup \iffalse{\fi \ifnum0=`}\fi
672
+ \toks@{}\def\tabu@stack{b}%
673
+ \expandafter\tabu@collectbody\expandafter\tabu@quickrule
674
+ \expandafter\endgroup
675
+ \fi
676
+ }% \tabu@nestedmeasure
677
+ \def\tabu@quickrule {\indent\vrule height\z@ depth\z@ width\tabu@target}
678
+ %% \tabu@setup \tabu@init \tabu@indent
679
+ \def\tabu@setup{\tabu@alloc@
680
+ \ifcase \tabu@nested
681
+ \ifmmode \else \iftabu@spread\else \ifdim\tabu@target=\z@
682
+ \let\tabu@afterendpar \par
683
+ \fi\fi\fi
684
+ \def\tabu@aligndefault{c}\tabu@init \tabu@indent
685
+ \else % <nested tabu>
686
+ \def\tabu@aligndefault{t}\let\tabudefaulttarget \linewidth
687
+ \fi
688
+ \let\tabu@thetarget \tabudefaulttarget \let\tabu@restored \@undefined
689
+ \edef\tabu@NC@list{\the\NC@list}\NC@list{\NC@do \tabu@rewritefirst}%
690
+ \everycr{}\let\@startpbox \tabu@startpbox % for nested tabu inside longtabu...
691
+ \let\@endpbox \tabu@endpbox % idem " " " " " "
692
+ \let\@tabarray \tabu@tabarray % idem " " " " " "
693
+ \tabu@setcleanup \tabu@setreset
694
+ }% \tabu@setup
695
+ \def\tabu@init{\tabu@starttimer \tabu@measuringfalse
696
+ \edef\tabu@hfuzz {\the\dimexpr\hfuzz+1sp}\global\tabu@footnotes{}%
697
+ \let\firsthline \tabu@firsthline \let\lasthline \tabu@lasthline
698
+ \let\firstline \tabu@firstline \let\lastline \tabu@lastline
699
+ \let\hline \tabu@hline \let\@xhline \tabu@xhline
700
+ \let\color \tabu@color \let\@arstrutbox \tabu@arstrutbox
701
+ \iftabu@colortbl\else\let\LT@@hline \tabu@LT@@hline \fi
702
+ \tabu@trivlist %<restore \\=\@normalcr inside lists>
703
+ \let\@footnotetext \tabu@footnotetext \let\@xfootnotetext \tabu@xfootnotetext
704
+ \let\@xfootnote \tabu@xfootnote \let\centering \tabu@centering
705
+ \let\raggedright \tabu@raggedright \let\raggedleft \tabu@raggedleft
706
+ \let\tabudecimal \tabu@tabudecimal \let\Centering \tabu@Centering
707
+ \let\RaggedRight \tabu@RaggedRight \let\RaggedLeft \tabu@RaggedLeft
708
+ \let\justifying \tabu@justifying \let\rowfont \tabu@rowfont
709
+ \let\fbox \tabu@fbox \let\color@b@x \tabu@color@b@x
710
+ \let\tabu@@everycr \everycr \let\tabu@@everypar \everypar
711
+ \let\tabu@prepnext@tokORI \prepnext@tok\let\prepnext@tok \tabu@prepnext@tok
712
+ \let\tabu@multicolumnORI\multicolumn \let\multicolumn \tabu@multicolumn
713
+ \let\tabu@startpbox \@startpbox % for nested tabu inside longtabu pfff !!!
714
+ \let\tabu@endpbox \@endpbox % idem " " " " " " "
715
+ \let\tabu@tabarray \@tabarray % idem " " " " " " "
716
+ \tabu@adl@fix \let\endarray \tabu@endarray % <fix> colortbl & arydshln (delarray)
717
+ \iftabu@colortbl\CT@everycr\expandafter{\expandafter\iftabu@everyrow \the\CT@everycr \fi}\fi
718
+ }% \tabu@init
719
+ \def\tabu@indent{% correction for indentation
720
+ \ifdim \parindent>\z@\ifx \linewidth\tabudefaulttarget
721
+ \everypar\expandafter{%
722
+ \the\everypar\everypar\expandafter{\the\everypar}%
723
+ \setbox\z@=\lastbox
724
+ \ifdim\wd\z@>\z@ \edef\tabu@thetarget
725
+ {\the\dimexpr -\wd\z@+\tabudefaulttarget}\fi
726
+ \box\z@}%
727
+ \fi\fi
728
+ }% \tabu@indent
729
+ \def\tabu@setcleanup {% saves last global assignments
730
+ \ifodd 1\ifmmode \else \iftabu@long \else 0\fi\fi\relax
731
+ \def\tabu@aftergroupcleanup{%
732
+ \def\tabu@aftergroupcleanup{\aftergroup\tabu@cleanup}}%
733
+ \else
734
+ \def\tabu@aftergroupcleanup{%
735
+ \aftergroup\aftergroup\aftergroup\tabu@cleanup
736
+ \let\tabu@aftergroupcleanup \relax}%
737
+ \fi
738
+ \let\tabu@arc@Gsave \tabu@arc@G
739
+ \let\tabu@arc@G \tabu@arc@L % <init>
740
+ \let\tabu@drsc@Gsave \tabu@drsc@G
741
+ \let\tabu@drsc@G \tabu@drsc@L % <init>
742
+ \let\tabu@ls@Gsave \tabu@ls@G
743
+ \let\tabu@ls@G \tabu@ls@L % <init>
744
+ \let\tabu@rc@Gsave \tabu@rc@G
745
+ \let\tabu@rc@G \tabu@rc@L % <init>
746
+ \let\tabu@evr@Gsave \tabu@evr@G
747
+ \let\tabu@evr@G \tabu@evr@L % <init>
748
+ \let\tabu@celllalign@save \tabu@celllalign
749
+ \let\tabu@cellralign@save \tabu@cellralign
750
+ \let\tabu@cellleft@save \tabu@cellleft
751
+ \let\tabu@cellright@save \tabu@cellright
752
+ \let\tabu@@celllalign@save \tabu@@celllalign
753
+ \let\tabu@@cellralign@save \tabu@@cellralign
754
+ \let\tabu@@cellleft@save \tabu@@cellleft
755
+ \let\tabu@@cellright@save \tabu@@cellright
756
+ \let\tabu@rowfontreset@save \tabu@rowfontreset
757
+ \let\tabu@@rowfontreset@save\tabu@@rowfontreset
758
+ \let\tabu@rowfontreset \@empty
759
+ \edef\tabu@alloc@save {\the\tabu@alloc}% restore at \tabu@reset
760
+ \edef\c@taburow@save {\the\c@taburow}%
761
+ \edef\tabu@naturalX@save {\the\tabu@naturalX}%
762
+ \let\tabu@naturalXmin@save \tabu@naturalXmin
763
+ \let\tabu@naturalXmax@save \tabu@naturalXmax
764
+ \let\tabu@mkarstrut@save \tabu@mkarstrut
765
+ \edef\tabu@clarstrut{%
766
+ \extrarowheight \the\dimexpr \ht\@arstrutbox-\ht\strutbox \relax
767
+ \extrarowdepth \the\dimexpr \dp\@arstrutbox-\dp\strutbox \relax
768
+ \let\noexpand\@arraystretch \@ne \noexpand\tabu@rearstrut}%
769
+ }% \tabu@setcleanup
770
+ \def\tabu@cleanup {\begingroup
771
+ \globaldefs\@ne \tabu@everyrowtrue
772
+ \let\tabu@arc@G \tabu@arc@Gsave
773
+ \let\CT@arc@ \tabu@arc@G
774
+ \let\tabu@drsc@G \tabu@drsc@Gsave
775
+ \let\CT@drsc@ \tabu@drsc@G
776
+ \let\tabu@ls@G \tabu@ls@Gsave
777
+ \let\tabu@ls@ \tabu@ls@G
778
+ \let\tabu@rc@G \tabu@rc@Gsave
779
+ \let\tabu@rc@ \tabu@rc@G
780
+ \let\CT@do@color \relax
781
+ \let\tabu@evr@G \tabu@evr@Gsave
782
+ \let\tabu@celllalign \tabu@celllalign@save
783
+ \let\tabu@cellralign \tabu@cellralign@save
784
+ \let\tabu@cellleft \tabu@cellleft@save
785
+ \let\tabu@cellright \tabu@cellright@save
786
+ \let\tabu@@celllalign \tabu@@celllalign@save
787
+ \let\tabu@@cellralign \tabu@@cellralign@save
788
+ \let\tabu@@cellleft \tabu@@cellleft@save
789
+ \let\tabu@@cellright \tabu@@cellright@save
790
+ \let\tabu@rowfontreset \tabu@rowfontreset@save
791
+ \let\tabu@@rowfontreset \tabu@@rowfontreset@save
792
+ \tabu@naturalX =\tabu@naturalX@save
793
+ \let\tabu@naturalXmax \tabu@naturalXmax@save
794
+ \let\tabu@naturalXmin \tabu@naturalXmin@save
795
+ \let\tabu@mkarstrut \tabu@mkarstrut@save
796
+ \c@taburow =\c@taburow@save
797
+ \ifcase \tabu@nested \tabu@alloc \m@ne\fi
798
+ \endgroup % <end of \globaldefs>
799
+ \ifcase \tabu@nested
800
+ \the\tabu@footnotes \global\tabu@footnotes{}%
801
+ \tabu@afterendpar \tabu@elapsedtime
802
+ \fi
803
+ \tabu@clarstrut
804
+ \everyrow\expandafter {\tabu@evr@G}%
805
+ }% \tabu@cleanup
806
+ \let\tabu@afterendpar \relax
807
+ \def\tabu@setreset {%
808
+ \edef\tabu@savedparams {% \relax for \tabu@message@save
809
+ \ifmmode \col@sep \the\arraycolsep
810
+ \else \col@sep \the\tabcolsep \fi \relax
811
+ \arrayrulewidth \the\arrayrulewidth \relax
812
+ \doublerulesep \the\doublerulesep \relax
813
+ \extratabsurround \the\extratabsurround \relax
814
+ \extrarowheight \the\extrarowheight \relax
815
+ \extrarowdepth \the\extrarowdepth \relax
816
+ \abovetabulinesep \the\abovetabulinesep \relax
817
+ \belowtabulinesep \the\belowtabulinesep \relax
818
+ \def\noexpand\arraystretch{\arraystretch}%
819
+ \ifdefined\minrowclearance \minrowclearance\the\minrowclearance\relax\fi}%
820
+ \begingroup
821
+ \@temptokena\expandafter{\tabu@savedparams}% => only for \savetabu / \usetabu
822
+ \ifx \tabu@arc@L\relax \else \tabu@setsave \tabu@arc@L \fi
823
+ \ifx \tabu@drsc@L\relax \else \tabu@setsave \tabu@drsc@L \fi
824
+ \tabu@setsave \tabu@ls@L \tabu@setsave \tabu@evr@L
825
+ \expandafter \endgroup \expandafter
826
+ \def\expandafter\tabu@saved@ \expandafter{\the\@temptokena
827
+ \let\tabu@arc@G \tabu@arc@L
828
+ \let\tabu@drsc@G \tabu@drsc@L
829
+ \let\tabu@ls@G \tabu@ls@L
830
+ \let\tabu@rc@G \tabu@rc@L
831
+ \let\tabu@evr@G \tabu@evr@L}%
832
+ \def\tabu@reset{\tabu@savedparams
833
+ \tabu@everyrowtrue \c@taburow \z@
834
+ \let\CT@arc@ \tabu@arc@L
835
+ \let\CT@drsc@ \tabu@drsc@L
836
+ \let\tabu@ls@ \tabu@ls@L
837
+ \let\tabu@rc@ \tabu@rc@L
838
+ \global\tabu@alloc \tabu@alloc@save
839
+ \everyrow\expandafter{\tabu@evr@L}}%
840
+ }% \tabu@reset
841
+ \def\tabu@setsave #1{\expandafter\tabu@sets@ve #1\@nil{#1}}
842
+ \long\def\tabu@sets@ve #1\@nil #2{\@temptokena\expandafter{\the\@temptokena \def#2{#1}}}
843
+ %% The Rewritting Process -------------------------------------------
844
+ \def\tabu@newcolumntype #1{%
845
+ \expandafter\tabu@new@columntype
846
+ \csname NC@find@\string#1\expandafter\endcsname
847
+ \csname NC@rewrite@\string#1\endcsname
848
+ {#1}%
849
+ }% \tabu@newcolumntype
850
+ \def\tabu@new@columntype #1#2#3{%
851
+ \def#1##1#3{\NC@{##1}}%
852
+ \let#2\relax \newcommand*#2%
853
+ }% \tabu@new@columntype
854
+ \def\tabu@privatecolumntype #1{%
855
+ \expandafter\tabu@private@columntype
856
+ \csname NC@find@\string#1\expandafter\endcsname
857
+ \csname NC@rewrite@\string#1\expandafter\endcsname
858
+ \csname tabu@NC@find@\string#1\expandafter\endcsname
859
+ \csname tabu@NC@rewrite@\string#1\endcsname
860
+ {#1}%
861
+ }% \tabu@privatecolumntype
862
+ \def\tabu@private@columntype#1#2#3#4{%
863
+ \g@addto@macro\tabu@privatecolumns{\let#1#3\let#2#4}%
864
+ \tabu@new@columntype#3#4%
865
+ }% \tabu@private@columntype
866
+ \let\tabu@privatecolumns \@empty
867
+ \newcommand*\tabucolumn [1]{\expandafter \def \expandafter
868
+ \tabu@highprioritycolumns\expandafter{\tabu@highprioritycolumns
869
+ \NC@do #1}}%
870
+ \let\tabu@highprioritycolumns \@empty
871
+ %% The | ``column'' : rewriting process --------------------------
872
+ \tabu@privatecolumntype |{\tabu@rewritevline}
873
+ \newcommand*\tabu@rewritevline[1][]{\tabu@vlinearg{#1}%
874
+ \expandafter \NC@find \tabu@rewritten}
875
+ \def\tabu@lines #1{%
876
+ \ifx|#1\else \tabu@privatecolumntype #1{\tabu@rewritevline}\fi
877
+ \NC@list\expandafter{\the\NC@list \NC@do #1}%
878
+ }% \tabu@lines@
879
+ \def\tabu@vlinearg #1{%
880
+ \ifx\\#1\\\def\tabu@thestyle {\tabu@ls@}%
881
+ \else\tabu@getline {#1}%
882
+ \fi
883
+ \def\tabu@rewritten ##1{\def\tabu@rewritten{!{##1\tabu@thevline}}%
884
+ }\expandafter\tabu@rewritten\expandafter{\tabu@thestyle}%
885
+ \expandafter \tabu@keepls \tabu@thestyle \@nil
886
+ }% \tabu@vlinearg
887
+ \def\tabu@keepls #1\@nil{%
888
+ \ifcat $\@cdr #1\@nil $%
889
+ \ifx \relax#1\else
890
+ \ifx \tabu@ls@#1\else
891
+ \let#1\relax
892
+ \xdef\tabu@mkpreambuffer{\tabu@mkpreambuffer
893
+ \tabu@savels\noexpand#1}\fi\fi\fi
894
+ }% \tabu@keepls
895
+ \def\tabu@thevline {\begingroup
896
+ \ifdefined\tabu@leaders
897
+ \setbox\@tempboxa=\vtop to\dimexpr
898
+ \ht\@arstrutbox+\dp\@arstrutbox{{\tabu@thevleaders}}%
899
+ \ht\@tempboxa=\ht\@arstrutbox \dp\@tempboxa=\dp\@arstrutbox
900
+ \box\@tempboxa
901
+ \else
902
+ \tabu@thevrule
903
+ \fi \endgroup
904
+ }% \tabu@thevline
905
+ \def\tabu@savels #1{%
906
+ \expandafter\let\csname\string#1\endcsname #1%
907
+ \expandafter\def\expandafter\tabu@reset\expandafter{\tabu@reset
908
+ \tabu@resetls#1}}%
909
+ \def\tabu@resetls #1{\expandafter\let\expandafter#1\csname\string#1\endcsname}%
910
+ %% \multicolumn inside tabu environment -----------------------------
911
+ \tabu@newcolumntype \tabu@rewritemulticolumn{%
912
+ \aftergroup \tabu@endrewritemulticolumn % after \@mkpream group
913
+ \NC@list{\NC@do *}\tabu@textbar \tabu@lines
914
+ \tabu@savedecl
915
+ \tabu@privatecolumns
916
+ \NC@list\expandafter{\the\expandafter\NC@list \tabu@NC@list}%
917
+ \let\tabu@savels \relax
918
+ \NC@find
919
+ }% \tabu@rewritemulticolumn
920
+ \def\tabu@endrewritemulticolumn{\gdef\tabu@mkpreambuffer{}\endgroup}
921
+ \def\tabu@multicolumn{\tabu@ifenvir \tabu@multic@lumn \tabu@multicolumnORI}
922
+ \long\def\tabu@multic@lumn #1#2#3{\multispan{#1}\begingroup
923
+ \tabu@everyrowtrue
924
+ \NC@list{\NC@do \tabu@rewritemulticolumn}%
925
+ \expandafter\@gobbletwo % gobbles \multispan{#1}
926
+ \tabu@multicolumnORI{#1}{\tabu@rewritemulticolumn #2}%
927
+ {\iftabuscantokens \tabu@rescan \else \expandafter\@firstofone \fi
928
+ {#3}}%
929
+ }% \tabu@multic@lumn
930
+ %% The X column(s): rewriting process -----------------------------
931
+ \tabu@privatecolumntype X[1][]{\begingroup \tabu@siunitx{\endgroup \tabu@rewriteX {#1}}}
932
+ \def\tabu@nosiunitx #1{#1{}{}\expandafter \NC@find \tabu@rewritten }
933
+ \def\tabu@siunitx #1{\@ifnextchar \bgroup
934
+ {\tabu@rewriteX@Ss{#1}}
935
+ {\tabu@nosiunitx{#1}}}
936
+ \def\tabu@rewriteX@Ss #1#2{\@temptokena{}%
937
+ \@defaultunits \let\tabu@temp =#2\relax\@nnil
938
+ \ifodd 1\ifx S\tabu@temp \else \ifx s\tabu@temp \else 0 \fi\fi
939
+ \def\NC@find{\def\NC@find >####1####2<####3\relax{#1 {####1}{####3}%
940
+ }\expandafter\NC@find \the\@temptokena \relax
941
+ }\expandafter\NC@rewrite@S \@gobble #2\relax
942
+ \else \tabu@siunitxerror
943
+ \fi
944
+ \expandafter \NC@find \tabu@rewritten
945
+ }% \tabu@rewriteX@Ss
946
+ \def\tabu@siunitxerror {\PackageError{tabu}{Not a S nor s column !
947
+ \MessageBreak X column can only embed siunitx S or s columns}\@ehd
948
+ }% \tabu@siunitxerror
949
+ \def\tabu@rewriteX #1#2#3{\tabu@Xarg {#1}{#2}{#3}%
950
+ \iftabu@measuring
951
+ \else \tabu@measuringtrue % first X column found in the preamble
952
+ \let\@halignto \relax \let\tabu@halignto \relax
953
+ \iftabu@spread \tabu@spreadtarget \tabu@target \tabu@target \z@
954
+ \else \tabu@spreadtarget \z@ \fi
955
+ \ifdim \tabu@target=\z@
956
+ \setlength\tabu@target \tabu@thetarget
957
+ \tabu@message{\tabu@message@defaulttarget}%
958
+ \else \tabu@message{\tabu@message@target}\fi
959
+ \fi
960
+ }% \tabu@rewriteX
961
+ \def\tabu@rewriteXrestore #1#2#3{\let\@halignto \relax
962
+ \def\tabu@rewritten{l}}
963
+ \def\tabu@Xarg #1#2#3{%
964
+ \advance\tabu@Xcol \@ne \let\tabu@Xlcr \@empty
965
+ \let\tabu@Xdisp \@empty \let\tabu@Xmath \@empty
966
+ \ifx\\#1\\% <shortcut when no option>
967
+ \def\tabu@rewritten{p}\tabucolX \p@ % <default coef = 1>
968
+ \else
969
+ \let\tabu@rewritten \@empty \let\tabu@temp \@empty \tabucolX \z@
970
+ \tabu@Xparse {}#1\relax
971
+ \fi
972
+ \tabu@Xrewritten{#2}{#3}%
973
+ }% \tabu@Xarg
974
+ \def\tabu@Xparse #1{\futurelet\@let@token \tabu@Xtest}
975
+ \expandafter\def\expandafter\tabu@Xparsespace\space{\tabu@Xparse{}}
976
+ \def\tabu@Xtest{%
977
+ \ifcase \ifx \relax\@let@token \z@ \else
978
+ \if ,\@let@token \m@ne\else
979
+ \if p\@let@token 1\else
980
+ \if m\@let@token 2\else
981
+ \if b\@let@token 3\else
982
+ \if l\@let@token 4\else
983
+ \if c\@let@token 5\else
984
+ \if r\@let@token 6\else
985
+ \if j\@let@token 7\else
986
+ \if L\@let@token 8\else
987
+ \if C\@let@token 9\else
988
+ \if R\@let@token 10\else
989
+ \if J\@let@token 11\else
990
+ \ifx \@sptoken\@let@token 12\else
991
+ \if .\@let@token 13\else
992
+ \if -\@let@token 13\else
993
+ \ifcat $\@let@token 14\else
994
+ 15\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\relax
995
+ \or \tabu@Xtype {p}%
996
+ \or \tabu@Xtype {m}%
997
+ \or \tabu@Xtype {b}%
998
+ \or \tabu@Xalign \raggedright\relax
999
+ \or \tabu@Xalign \centering\relax
1000
+ \or \tabu@Xalign \raggedleft\relax
1001
+ \or \tabu@Xalign \tabu@justify\relax
1002
+ \or \tabu@Xalign \RaggedRight\raggedright
1003
+ \or \tabu@Xalign \Centering\centering
1004
+ \or \tabu@Xalign \RaggedLeft\raggedleft
1005
+ \or \tabu@Xalign \justifying\tabu@justify
1006
+ \or \expandafter \tabu@Xparsespace
1007
+ \or \expandafter \tabu@Xcoef
1008
+ \or \expandafter \tabu@Xm@th
1009
+ \or \tabu@Xcoef{}%
1010
+ \else\expandafter \tabu@Xparse
1011
+ \fi
1012
+ }% \tabu@Xtest
1013
+ \def\tabu@Xalign #1#2{%
1014
+ \ifx \tabu@Xlcr\@empty \else \PackageWarning{tabu}
1015
+ {Duplicate horizontal alignment specification}\fi
1016
+ \ifdefined#1\def\tabu@Xlcr{#1}\let#1\relax
1017
+ \else \def\tabu@Xlcr{#2}\let#2\relax\fi
1018
+ \expandafter\tabu@Xparse
1019
+ }% \tabu@Xalign
1020
+ \def\tabu@Xtype #1{%
1021
+ \ifx \tabu@rewritten\@empty \else \PackageWarning{tabu}
1022
+ {Duplicate vertical alignment specification}\fi
1023
+ \def\tabu@rewritten{#1}\expandafter\tabu@Xparse
1024
+ }% \tabu@Xtype
1025
+ \def\tabu@Xcoef#1{\edef\tabu@temp{\tabu@temp#1}%
1026
+ \afterassignment\tabu@Xc@ef \tabu@cnt\number\if-#10\fi
1027
+ }% \tabu@Xcoef
1028
+ \def\tabu@Xc@ef{\advance\tabucolX \tabu@temp\the\tabu@cnt\p@
1029
+ \tabu@Xparse{}%
1030
+ }% \tabu@Xc@ef
1031
+ \def\tabu@Xm@th #1{\futurelet \@let@token \tabu@Xd@sp}
1032
+ \def\tabu@Xd@sp{\let\tabu@Xmath=$%
1033
+ \ifx $\@let@token \def\tabu@Xdisp{\displaystyle}%
1034
+ \expandafter\tabu@Xparse
1035
+ \else \expandafter\tabu@Xparse\expandafter{\expandafter}%
1036
+ \fi
1037
+ }% \tabu@Xd@sp
1038
+ \def\tabu@Xrewritten {%
1039
+ \ifx \tabu@rewritten\@empty \def\tabu@rewritten{p}\fi
1040
+ \ifdim \tabucolX<\z@ \tabu@negcoeftrue
1041
+ \else\ifdim \tabucolX=\z@ \tabucolX \p@
1042
+ \fi\fi
1043
+ \edef\tabu@temp{{\the\tabu@Xcol}{\tabu@strippt\tabucolX}}%
1044
+ \edef\tabu@Xcoefs{\tabu@Xcoefs \tabu@ \tabu@temp}%
1045
+ \edef\tabu@rewritten ##1##2{\def\noexpand\tabu@rewritten{%
1046
+ >{\tabu@Xlcr \ifx$\tabu@Xmath$\tabu@Xdisp\fi ##1}%
1047
+ \tabu@rewritten {\tabu@hsize \tabu@temp}%
1048
+ <{##2\ifx$\tabu@Xmath$\fi}}%
1049
+ }\tabu@rewritten
1050
+ }% \tabu@Xrewritten
1051
+ \def\tabu@hsize #1#2{%
1052
+ \ifdim #2\p@<\z@
1053
+ \ifdim \tabucolX=\maxdimen \tabu@wd{#1}\else
1054
+ \ifdim \tabu@wd{#1}<-#2\tabucolX \tabu@wd{#1}\else -#2\tabucolX\fi
1055
+ \fi
1056
+ \else #2\tabucolX
1057
+ \fi
1058
+ }% \tabu@hsize
1059
+ %% \usetabu and \preamble: rewritting process ---------------------
1060
+ \tabu@privatecolumntype \usetabu [1]{%
1061
+ \ifx\\#1\\\tabu@saveerr{}\else
1062
+ \@ifundefined{tabu@saved@\string#1}
1063
+ {\tabu@saveerr{#1}}
1064
+ {\let\tabu@rewriteX \tabu@rewriteXrestore
1065
+ \csname tabu@saved@\string#1\expandafter\endcsname\expandafter\@ne}%
1066
+ \fi
1067
+ }% \NC@rewrite@\usetabu
1068
+ \tabu@privatecolumntype \preamble [1]{%
1069
+ \ifx\\#1\\\tabu@saveerr{}\else
1070
+ \@ifundefined{tabu@saved@\string#1}
1071
+ {\tabu@saveerr{#1}}
1072
+ {\csname tabu@saved@\string#1\expandafter\endcsname\expandafter\z@}%
1073
+ \fi
1074
+ }% \NC@rewrite@\preamble
1075
+ %% Controlling the rewritting process -------------------------------
1076
+ \tabu@newcolumntype \tabu@rewritefirst{%
1077
+ \iftabu@long \aftergroup \tabu@longpream % <the whole implementation is here !>
1078
+ \else \aftergroup \tabu@pream
1079
+ \fi
1080
+ \let\tabu@ \relax \let\tabu@hsize \relax
1081
+ \let\tabu@Xcoefs \@empty \let\tabu@savels \relax
1082
+ \tabu@Xcol \z@ \tabu@cnt \tw@
1083
+ \gdef\tabu@mkpreambuffer{\tabu@{}}\tabu@measuringfalse
1084
+ \global\setbox\@arstrutbox \box\@arstrutbox
1085
+ \NC@list{\NC@do *}\tabu@textbar \tabu@lines
1086
+ \NC@list\expandafter{\the\NC@list \NC@do X}%
1087
+ \iftabu@siunitx % <siunitx S and s columns>
1088
+ \NC@list\expandafter{\the\NC@list \NC@do S\NC@do s}\fi
1089
+ \NC@list\expandafter{\the\expandafter\NC@list \tabu@highprioritycolumns}%
1090
+ \expandafter\def\expandafter\tabu@NC@list\expandafter{%
1091
+ \the\expandafter\NC@list \tabu@NC@list}% % * | X S <original>
1092
+ \NC@list\expandafter{\expandafter \NC@do \expandafter\usetabu
1093
+ \expandafter \NC@do \expandafter\preamble
1094
+ \the\NC@list \NC@do \tabu@rewritemiddle
1095
+ \NC@do \tabu@rewritelast}%
1096
+ \tabu@savedecl
1097
+ \tabu@privatecolumns
1098
+ \edef\tabu@prev{\the\@temptokena}\NC@find \tabu@rewritemiddle
1099
+ }% NC@rewrite@\tabu@rewritefirst
1100
+ \tabu@newcolumntype \tabu@rewritemiddle{%
1101
+ \edef\tabu@temp{\the\@temptokena}\NC@find \tabu@rewritelast
1102
+ }% \NC@rewrite@\tabu@rewritemiddle
1103
+ \tabu@newcolumntype \tabu@rewritelast{%
1104
+ \ifx \tabu@temp\tabu@prev \advance\tabu@cnt \m@ne
1105
+ \NC@list\expandafter{\tabu@NC@list \NC@do \tabu@rewritemiddle
1106
+ \NC@do \tabu@rewritelast}%
1107
+ \else \let\tabu@prev\tabu@temp
1108
+ \fi
1109
+ \ifcase \tabu@cnt \expandafter\tabu@endrewrite
1110
+ \else \expandafter\NC@find \expandafter\tabu@rewritemiddle
1111
+ \fi
1112
+ }% \NC@rewrite@\tabu@rewritelast
1113
+ %% Choosing the strategy --------------------------------------------
1114
+ \def\tabu@endrewrite {%
1115
+ \let\tabu@temp \NC@find
1116
+ \ifx \@arrayright\relax \let\@arrayright \@empty \fi
1117
+ \count@=%
1118
+ \ifx \@finalstrut\tabu@finalstrut \z@ % outer in mode 0 print
1119
+ \iftabu@measuring
1120
+ \xdef\tabu@mkpreambuffer{\tabu@mkpreambuffer
1121
+ \tabu@target \csname tabu@\the\tabu@nested.T\endcsname
1122
+ \tabucolX \csname tabu@\the\tabu@nested.X\endcsname
1123
+ \edef\@halignto {\ifx\@arrayright\@empty to\tabu@target\fi}}%
1124
+ \fi
1125
+ \else\iftabu@measuring 4 % X columns
1126
+ \xdef\tabu@mkpreambuffer{\tabu@{\tabu@mkpreambuffer
1127
+ \tabu@target \the\tabu@target
1128
+ \tabu@spreadtarget \the\tabu@spreadtarget}%
1129
+ \def\noexpand\tabu@Xcoefs{\tabu@Xcoefs}%
1130
+ \edef\tabu@halignto{\ifx \@arrayright\@empty to\tabu@target\fi}}%
1131
+ \let\tabu@Xcoefs \relax
1132
+ \else\ifcase\tabu@nested \thr@@ % outer, no X
1133
+ \global\let\tabu@afterendpar \relax
1134
+ \else \@ne % inner, no X, outer in mode 1 or 2
1135
+ \fi
1136
+ \ifdefined\tabu@usetabu
1137
+ \else \ifdim\tabu@target=\z@
1138
+ \else \let\tabu@temp \tabu@extracolsep
1139
+ \fi\fi
1140
+ \fi
1141
+ \fi
1142
+ \xdef\tabu@mkpreambuffer{\count@ \the\count@ \tabu@mkpreambuffer}%
1143
+ \tabu@temp
1144
+ }% \tabu@endrewrite
1145
+ \def\tabu@extracolsep{\@defaultunits \expandafter\let
1146
+ \expandafter\tabu@temp \expandafter=\the\@temptokena \relax\@nnil
1147
+ \ifx \tabu@temp\@sptoken
1148
+ \expandafter\tabu@gobblespace \expandafter\tabu@extracolsep
1149
+ \else
1150
+ \edef\tabu@temp{\noexpand\NC@find
1151
+ \if |\noexpand\tabu@temp @%
1152
+ \else\if !\noexpand\tabu@temp @%
1153
+ \else !%
1154
+ \fi\fi
1155
+ {\noexpand\extracolsep\noexpand\@flushglue}}%
1156
+ \fi
1157
+ \tabu@temp
1158
+ }% \tabu@extrac@lsep
1159
+ %% Implementing the strategy ----------------------------------------
1160
+ \long\def\tabu@pream #1\@preamble {%
1161
+ \let\tabu@ \tabu@@ \tabu@mkpreambuffer \tabu@aftergroupcleanup
1162
+ \NC@list\expandafter {\tabu@NC@list}% in case of nesting...
1163
+ \ifdefined\tabu@usetabu \tabu@usetabu \tabu@target \z@ \fi
1164
+ \let\tabu@savedpreamble \@preamble
1165
+ \global\let\tabu@elapsedtime \relax
1166
+ \tabu@thebody ={#1\tabu@aftergroupcleanup}%
1167
+ \tabu@thebody =\expandafter{\the\expandafter\tabu@thebody
1168
+ \@preamble}%
1169
+ \edef\tabuthepreamble {\the\tabu@thebody}% ( no @ allowed for \scantokens )
1170
+ \tabu@select
1171
+ }% \tabu@pream
1172
+ \long\def\tabu@longpream #1\LT@bchunk #2\LT@bchunk{%
1173
+ \let\tabu@ \tabu@@ \tabu@mkpreambuffer \tabu@aftergroupcleanup
1174
+ \NC@list\expandafter {\tabu@NC@list}% in case of nesting...
1175
+ \let\tabu@savedpreamble \@preamble
1176
+ \global\let\tabu@elapsedtime \relax
1177
+ \tabu@thebody ={#1\LT@bchunk #2\tabu@aftergroupcleanup \LT@bchunk}%
1178
+ \edef\tabuthepreamble {\the\tabu@thebody}% ( no @ allowed for \scantokens )
1179
+ \tabu@select
1180
+ }% \tabu@longpream
1181
+ \def\tabu@select {%
1182
+ \ifnum\tabu@nested>\z@ \tabuscantokensfalse \fi
1183
+ \ifnum \count@=\@ne \iftabu@measuring \count@=\tw@ \fi\fi
1184
+ \ifcase \count@
1185
+ \global\let\tabu@elapsedtime \relax
1186
+ \tabu@seteverycr
1187
+ \expandafter \tabuthepreamble % vertical adjustment (inheritated from outer)
1188
+ \or % exit in vertical measure + struts per cell because no X and outer in mode 3
1189
+ \tabu@evr{\tabu@verticalinit}\tabu@celllalign@def{\tabu@verticalmeasure}%
1190
+ \def\tabu@cellralign{\tabu@verticalspacing}%
1191
+ \tabu@seteverycr
1192
+ \expandafter \tabuthepreamble
1193
+ \or % exit without measure because no X and outer in mode 4
1194
+ \tabu@evr{}\tabu@celllalign@def{}\let\tabu@cellralign \@empty
1195
+ \tabu@seteverycr
1196
+ \expandafter \tabuthepreamble
1197
+ \else % needs trials
1198
+ \tabu@evr{}\tabu@celllalign@def{}\let\tabu@cellralign \@empty
1199
+ \tabu@savecounters
1200
+ \expandafter \tabu@setstrategy
1201
+ \fi
1202
+ }% \tabu@select
1203
+ \def\tabu@@ {\gdef\tabu@mkpreambuffer}
1204
+ %% Protections to set up before trials ------------------------------
1205
+ \def\tabu@setstrategy {\begingroup % <trials group>
1206
+ \tabu@trialh@@k \tabu@cnt \z@ % number of trials
1207
+ \hbadness \@M \let\hbadness \@tempcnta
1208
+ \hfuzz \maxdimen \let\hfuzz \@tempdima
1209
+ \let\write \tabu@nowrite\let\GenericError \tabu@GenericError
1210
+ \let\savetabu \@gobble \let\tabudefaulttarget \linewidth
1211
+ \let\@footnotetext \@gobble \let\@xfootnote \tabu@xfootnote
1212
+ \let\color \tabu@nocolor\let\rowcolor \tabu@norowcolor
1213
+ \let\tabu@aftergroupcleanup \relax % only after the last trial
1214
+ \tabu@mkpreambuffer
1215
+ \ifnum \count@>\thr@@ \let\@halignto \@empty \tabucolX@init
1216
+ \def\tabu@lasttry{\m@ne\p@}\fi
1217
+ \begingroup \iffalse{\fi \ifnum0=`}\fi
1218
+ \toks@{}\def\tabu@stack{b}\iftabuscantokens \endlinechar=10 \obeyspaces \fi %
1219
+ \tabu@collectbody \tabu@strategy %
1220
+ }% \tabu@setstrategy
1221
+ \def\tabu@savecounters{%
1222
+ \def\@elt ##1{\csname c@##1\endcsname\the\csname c@##1\endcsname}%
1223
+ \edef\tabu@clckpt {\begingroup \globaldefs=\@ne \cl@@ckpt \endgroup}\let\@elt \relax
1224
+ }% \tabu@savecounters
1225
+ \def\tabucolX@init {% \tabucolX <= \tabu@target / (sum coefs > 0)
1226
+ \dimen@ \z@ \tabu@Xsum \z@ \tabucolX \z@ \let\tabu@ \tabu@Xinit \tabu@Xcoefs
1227
+ \ifdim \dimen@>\z@
1228
+ \@tempdima \dimexpr \tabu@target *\p@/\dimen@ + \tabu@hfuzz\relax
1229
+ \ifdim \tabucolX<\@tempdima \tabucolX \@tempdima \fi
1230
+ \fi
1231
+ }% \tabucolX@init
1232
+ \def\tabu@Xinit #1#2{\tabu@Xcol #1 \advance \tabu@Xsum
1233
+ \ifdim #2\p@>\z@ #2\p@ \advance\dimen@ #2\p@
1234
+ \else -#2\p@ \tabu@negcoeftrue
1235
+ \@tempdima \dimexpr \tabu@target*\p@/\dimexpr-#2\p@\relax \relax
1236
+ \ifdim \tabucolX<\@tempdima \tabucolX \@tempdima \fi
1237
+ \tabu@wddef{#1}{0pt}%
1238
+ \fi
1239
+ }% \tabu@Xinit
1240
+ %% Collecting the environment body ----------------------------------
1241
+ \long\def\tabu@collectbody #1#2\end #3{%
1242
+ \edef\tabu@stack{\tabu@pushbegins #2\begin\end\expandafter\@gobble\tabu@stack}%
1243
+ \ifx \tabu@stack\@empty
1244
+ \toks@\expandafter{\expandafter\tabu@thebody\expandafter{\the\toks@ #2}%
1245
+ \def\tabu@end@envir{\end{#3}}%
1246
+ \iftabuscantokens
1247
+ \iftabu@long \def\tabu@endenvir {\end{#3}\tabu@gobbleX}%
1248
+ \else \def\tabu@endenvir {\let\endarray \@empty
1249
+ \end{#3}\tabu@gobbleX}%
1250
+ \fi
1251
+ \else \def\tabu@endenvir {\end{#3}}\fi}%
1252
+ \let\tabu@collectbody \tabu@endofcollect
1253
+ \else\def\tabu@temp{#3}%
1254
+ \ifx \tabu@temp\@empty \toks@\expandafter{\the\toks@ #2\end }%
1255
+ \else \ifx\tabu@temp\tabu@@spxiii \toks@\expandafter{\the\toks@ #2\end #3}%
1256
+ \else \ifx\tabu@temp\tabu@X \toks@\expandafter{\the\toks@ #2\end #3}%
1257
+ \else \toks@\expandafter{\the\toks@ #2\end{#3}}%
1258
+ \fi\fi\fi
1259
+ \fi
1260
+ \tabu@collectbody{#1}%
1261
+ }% \tabu@collectbody
1262
+ \long\def\tabu@pushbegins#1\begin#2{\ifx\end#2\else b\expandafter\tabu@pushbegins\fi}%
1263
+ \def\tabu@endofcollect #1{\ifnum0=`{}\fi
1264
+ \expandafter\endgroup \the\toks@ #1%
1265
+ }% \tabu@endofcollect
1266
+ %% The trials: switching between strategies -------------------------
1267
+ \def\tabu@strategy {\relax % stops \count@ assignment !
1268
+ \ifcase\count@ % case 0 = print with vertical adjustment (outer is finished)
1269
+ \expandafter \tabu@endoftrials
1270
+ \or % case 1 = exit in vertical measure (outer in mode 3)
1271
+ \expandafter\xdef\csname tabu@\the\tabu@nested.T\endcsname{\the\tabu@target}%
1272
+ \expandafter\xdef\csname tabu@\the\tabu@nested.X\endcsname{\the\tabucolX}%
1273
+ \expandafter \tabu@endoftrials
1274
+ \or % case 2 = exit with a rule replacing the table (outer in mode 4)
1275
+ \expandafter \tabu@quickend
1276
+ \or % case 3 = outer is in mode 3 because of no X
1277
+ \begingroup
1278
+ \tabu@evr{\tabu@verticalinit}\tabu@celllalign@def{\tabu@verticalmeasure}%
1279
+ \def\tabu@cellralign{\tabu@verticalspacing}%
1280
+ \expandafter \tabu@measuring
1281
+ \else % case 4 = horizontal measure
1282
+ \begingroup
1283
+ \global\let\tabu@elapsedtime \tabu@message@etime
1284
+ \long\def\multicolumn##1##2##3{\multispan{##1}}%
1285
+ \let\tabu@startpboxORI \@startpbox
1286
+ \iftabu@spread
1287
+ \def\tabu@naturalXmax {\z@}%
1288
+ \let\tabu@naturalXmin \tabu@naturalXmax
1289
+ \tabu@evr{\global\tabu@naturalX \z@}%
1290
+ \let\@startpbox \tabu@startpboxmeasure
1291
+ \else\iftabu@negcoef
1292
+ \let\@startpbox \tabu@startpboxmeasure
1293
+ \else \let\@startpbox \tabu@startpboxquick
1294
+ \fi\fi
1295
+ \expandafter \tabu@measuring
1296
+ \fi
1297
+ }% \tabu@strategy
1298
+ \def\tabu@measuring{\expandafter \tabu@trial \expandafter
1299
+ \count@ \the\count@ \tabu@endtrial
1300
+ }% \tabu@measuring
1301
+ \def\tabu@trial{\iftabu@long \tabu@longtrial \else \tabu@shorttrial \fi}
1302
+ \def\tabu@shorttrial {\setbox\tabu@box \hbox\bgroup \tabu@seteverycr
1303
+ \ifx \tabu@savecounters\relax \else
1304
+ \let\tabu@savecounters \relax \tabu@clckpt \fi
1305
+ $\iftabuscantokens \tabu@rescan \else \expandafter\@secondoftwo \fi
1306
+ \expandafter{\expandafter \tabuthepreamble
1307
+ \the\tabu@thebody
1308
+ \csname tabu@adl@endtrial\endcsname
1309
+ \endarray}$\egroup % got \tabu@box
1310
+ }% \tabu@shorttrial
1311
+ \def\tabu@longtrial {\setbox\tabu@box \hbox\bgroup \tabu@seteverycr
1312
+ \ifx \tabu@savecounters\relax \else
1313
+ \let\tabu@savecounters \relax \tabu@clckpt \fi
1314
+ \iftabuscantokens \tabu@rescan \else \expandafter\@secondoftwo \fi
1315
+ \expandafter{\expandafter \tabuthepreamble
1316
+ \the\tabu@thebody
1317
+ \tabuendlongtrial}\egroup % got \tabu@box
1318
+ }% \tabu@longtrial
1319
+ \def\tabuendlongtrial{% no @ allowed for \scantokens
1320
+ \LT@echunk \global\setbox\@ne \hbox{\unhbox\@ne}\kern\wd\@ne
1321
+ \LT@get@widths
1322
+ }% \tabuendlongtrial
1323
+ \def\tabu@adl@endtrial{% <arydshln in nested trials - problem for global column counters!>
1324
+ \crcr \noalign{\global\adl@ncol \tabu@nbcols}}% anything global is crap, junky and fails !
1325
+ \def\tabu@seteverycr {\tabu@reset
1326
+ \everycr \expandafter{\the\everycr \tabu@everycr}%
1327
+ \let\everycr \tabu@noeverycr % <for ialign>
1328
+ }% \tabu@seteverycr
1329
+ \def\tabu@noeverycr{{\aftergroup\tabu@restoreeverycr \afterassignment}\toks@}
1330
+ \def\tabu@restoreeverycr {\let\everycr \tabu@@everycr}
1331
+ \def\tabu@everycr {\iftabu@everyrow \noalign{\tabu@everyrow}\fi}
1332
+ \def\tabu@endoftrials {%
1333
+ \iftabuscantokens \expandafter\@firstoftwo
1334
+ \else \expandafter\@secondoftwo
1335
+ \fi
1336
+ {\expandafter \tabu@closetrialsgroup \expandafter
1337
+ \tabu@rescan \expandafter{%
1338
+ \expandafter\tabuthepreamble
1339
+ \the\expandafter\tabu@thebody
1340
+ \iftabu@long \else \endarray \fi}}
1341
+ {\expandafter\tabu@closetrialsgroup \expandafter
1342
+ \tabuthepreamble
1343
+ \the\tabu@thebody}%
1344
+ \tabu@endenvir % Finish !
1345
+ }% \tabu@endoftrials
1346
+ \def\tabu@closetrialsgroup {%
1347
+ \toks@\expandafter{\tabu@endenvir}%
1348
+ \edef\tabu@bufferX{\endgroup
1349
+ \tabucolX \the\tabucolX
1350
+ \tabu@target \the\tabu@target
1351
+ \tabu@cnt \the\tabu@cnt
1352
+ \def\noexpand\tabu@endenvir{\the\toks@}%
1353
+ %Quid de \@halignto = \tabu@halignto ??
1354
+ }% \tabu@bufferX
1355
+ \tabu@bufferX
1356
+ \ifcase\tabu@nested % print out (outer in mode 0)
1357
+ \global\tabu@cnt \tabu@cnt
1358
+ \tabu@evr{\tabu@verticaldynamicadjustment}%
1359
+ \tabu@celllalign@def{\everypar{}}\let\tabu@cellralign \@empty
1360
+ \let\@finalstrut \tabu@finalstrut
1361
+ \else % vertical measure of nested tabu
1362
+ \tabu@evr{\tabu@verticalinit}%
1363
+ \tabu@celllalign@def{\tabu@verticalmeasure}%
1364
+ \def\tabu@cellralign{\tabu@verticalspacing}%
1365
+ \fi
1366
+ \tabu@clckpt \let\@halignto \tabu@halignto
1367
+ \let\@halignto \@empty
1368
+ \tabu@seteverycr
1369
+ \ifdim \tabustrutrule>\z@ \ifnum\tabu@nested=\z@
1370
+ \setbox\@arstrutbox \box\voidb@x % force \@arstrutbox to be rebuilt (visible struts)
1371
+ \fi\fi
1372
+ }% \tabu@closetrialsgroup
1373
+ \def\tabu@quickend {\expandafter \endgroup \expandafter
1374
+ \tabu@target \the\tabu@target \tabu@quickrule
1375
+ \let\endarray \relax \tabu@endenvir
1376
+ }% \tabu@quickend
1377
+ \def\tabu@endtrial {\relax % stops \count@ assignment !
1378
+ \ifcase \count@ \tabu@err % case 0 = impossible here
1379
+ \or \tabu@err % case 1 = impossible here
1380
+ \or \tabu@err % case 2 = impossible here
1381
+ \or % case 3 = outer goes into mode 0
1382
+ \def\tabu@bufferX{\endgroup}\count@ \z@
1383
+ \else % case 4 = outer goes into mode 3
1384
+ \iftabu@spread \tabu@spreadarith % inner into mode 1 (outer in mode 3)
1385
+ \else \tabu@arith % or 2 (outer in mode 4)
1386
+ \fi
1387
+ \count@=%
1388
+ \ifcase\tabu@nested \thr@@ % outer goes into mode 3
1389
+ \else\iftabu@measuring \tw@ % outer is in mode 4
1390
+ \else \@ne % outer is in mode 3
1391
+ \fi\fi
1392
+ \edef\tabu@bufferX{\endgroup
1393
+ \tabucolX \the\tabucolX
1394
+ \tabu@target \the\tabu@target}%
1395
+ \fi
1396
+ \expandafter \tabu@bufferX \expandafter
1397
+ \count@ \the\count@ \tabu@strategy
1398
+ }% \tabu@endtrial
1399
+ \def\tabu@err{\errmessage{(tabu) Internal impossible error! (\count@=\the\count@)}}
1400
+ %% The algorithms: compute the widths / stop or go on ---------------
1401
+ \def\tabu@arithnegcoef {%
1402
+ \@tempdima \z@ \dimen@ \z@ \let\tabu@ \tabu@arith@negcoef \tabu@Xcoefs
1403
+ }% \tabu@arithnegcoef
1404
+ \def\tabu@arith@negcoef #1#2{%
1405
+ \ifdim #2\p@>\z@ \advance\dimen@ #2\p@ % saturated by definition
1406
+ \advance\@tempdima #2\tabucolX
1407
+ \else
1408
+ \ifdim -#2\tabucolX <\tabu@wd{#1}% c_i X < natural width <= \tabu@target-> saturated
1409
+ \advance\dimen@ -#2\p@
1410
+ \advance\@tempdima -#2\tabucolX
1411
+ \else
1412
+ \advance\@tempdima \tabu@wd{#1}% natural width <= c_i X => neutralised
1413
+ \ifdim \tabu@wd{#1}<\tabu@target \else % neutralised
1414
+ \advance\dimen@ -#2\p@ % saturated (natural width = tabu@target)
1415
+ \fi
1416
+ \fi
1417
+ \fi
1418
+ }% \tabu@arith@negcoef
1419
+ \def\tabu@givespace #1#2{% here \tabu@DELTA < \z@
1420
+ \ifdim \@tempdima=\z@
1421
+ \tabu@wddef{#1}{\the\dimexpr -\tabu@DELTA*\p@/\tabu@Xsum}%
1422
+ \else
1423
+ \tabu@wddef{#1}{\the\dimexpr \tabu@hsize{#1}{#2}
1424
+ *(\p@ -\tabu@DELTA*\p@/\@tempdima)/\p@\relax}%
1425
+ \fi
1426
+ }% \tabu@givespace
1427
+ \def\tabu@arith {\advance\tabu@cnt \@ne
1428
+ \ifnum \tabu@cnt=\@ne \tabu@message{\tabu@titles}\fi
1429
+ \tabu@arithnegcoef
1430
+ \@tempdimb \dimexpr \wd\tabu@box -\@tempdima \relax % <incompressible material>
1431
+ \tabu@DELTA = \dimexpr \wd\tabu@box - \tabu@target \relax
1432
+ \tabu@message{\tabu@message@arith}%
1433
+ \ifdim \tabu@DELTA <\tabu@hfuzz
1434
+ \ifdim \tabu@DELTA<\z@ % wd (tabu)<\tabu@target ?
1435
+ \let\tabu@ \tabu@givespace \tabu@Xcoefs
1436
+ \advance\@tempdima \@tempdimb \advance\@tempdima -\tabu@DELTA % for message
1437
+ \else % already converged: nothing to do but nearly impossible...
1438
+ \fi
1439
+ \tabucolX \maxdimen
1440
+ \tabu@measuringfalse
1441
+ \else % need for narrower X columns
1442
+ \tabucolX =\dimexpr (\@tempdima -\tabu@DELTA) *\p@/\tabu@Xsum \relax
1443
+ \tabu@measuringtrue
1444
+ \@whilesw \iftabu@measuring\fi {%
1445
+ \advance\tabu@cnt \@ne
1446
+ \tabu@arithnegcoef
1447
+ \tabu@DELTA =\dimexpr \@tempdima+\@tempdimb -\tabu@target \relax % always < 0 here
1448
+ \tabu@message{\tabu@header
1449
+ \tabu@msgalign \tabucolX { }{ }{ }{ }{ }\@@
1450
+ \tabu@msgalign \@tempdima+\@tempdimb { }{ }{ }{ }{ }\@@
1451
+ \tabu@msgalign \tabu@target { }{ }{ }{ }{ }\@@
1452
+ \tabu@msgalign@PT \dimen@ { }{}{}{}{}{}{}\@@
1453
+ \ifdim -\tabu@DELTA<\tabu@hfuzz \tabu@spaces target ok\else
1454
+ \tabu@msgalign \dimexpr -\tabu@DELTA *\p@/\dimen@ {}{}{}{}{}\@@
1455
+ \fi}%
1456
+ \ifdim -\tabu@DELTA<\tabu@hfuzz
1457
+ \advance\@tempdima \@tempdimb % for message
1458
+ \tabu@measuringfalse
1459
+ \else
1460
+ \advance\tabucolX \dimexpr -\tabu@DELTA *\p@/\dimen@ \relax
1461
+ \fi
1462
+ }%
1463
+ \fi
1464
+ \tabu@message{\tabu@message@reached}%
1465
+ \edef\tabu@bufferX{\endgroup \tabu@cnt \the\tabu@cnt
1466
+ \tabucolX \the\tabucolX
1467
+ \tabu@target \the\tabu@target}%
1468
+ }% \tabu@arith
1469
+ \def\tabu@spreadarith {%
1470
+ \dimen@ \z@ \@tempdima \tabu@naturalXmax \let\tabu@ \tabu@spread@arith \tabu@Xcoefs
1471
+ \edef\tabu@naturalXmin {\the\dimexpr\tabu@naturalXmin*\dimen@/\p@}%
1472
+ \@tempdimc =\dimexpr \wd\tabu@box -\tabu@naturalXmax+\tabu@naturalXmin \relax
1473
+ \iftabu@measuring
1474
+ \tabu@target =\dimexpr \@tempdimc+\tabu@spreadtarget \relax
1475
+ \edef\tabu@bufferX{\endgroup \tabucolX \the\tabucolX \tabu@target\the\tabu@target}%
1476
+ \else
1477
+ \tabu@message{\tabu@message@spreadarith}%
1478
+ \ifdim \dimexpr \@tempdimc+\tabu@spreadtarget >\tabu@target
1479
+ \tabu@message{(tabu) spread
1480
+ \ifdim \@tempdimc>\tabu@target useless here: default target used%
1481
+ \else too large: reduced to fit default target\fi.}%
1482
+ \else
1483
+ \tabu@target =\dimexpr \@tempdimc+\tabu@spreadtarget \relax
1484
+ \tabu@message{(tabu) spread: New target set to \the\tabu@target^^J}%
1485
+ \fi
1486
+ \begingroup \let\tabu@wddef \@gobbletwo
1487
+ \@tempdimb \@tempdima
1488
+ \tabucolX@init
1489
+ \tabu@arithnegcoef
1490
+ \wd\tabu@box =\dimexpr \wd\tabu@box +\@tempdima-\@tempdimb \relax
1491
+ \expandafter\endgroup \expandafter\tabucolX \the\tabucolX
1492
+ \tabu@arith
1493
+ \fi
1494
+ }% \tabu@spreadarith
1495
+ \def\tabu@spread@arith #1#2{%
1496
+ \ifdim #2\p@>\z@ \advance\dimen@ #2\p@
1497
+ \else \advance\@tempdima \tabu@wd{#1}\relax
1498
+ \fi
1499
+ }% \tabu@spread@arith
1500
+ %% Reporting in the .log file ---------------------------------------
1501
+ \def\tabu@message@defaulttarget{%
1502
+ \ifnum\tabu@nested=\z@^^J(tabu) Default target:
1503
+ \ifx\tabudefaulttarget\linewidth \string\linewidth
1504
+ \ifdim \tabu@thetarget=\linewidth \else
1505
+ -\the\dimexpr\linewidth-\tabu@thetarget\fi =
1506
+ \else\ifx\tabudefaulttarget\linegoal\string\linegoal=
1507
+ \fi\fi
1508
+ \else (tabu) Default target (nested): \fi
1509
+ \the\tabu@target \on@line
1510
+ \ifnum\tabu@nested=\z@ , page \the\c@page\fi}
1511
+ \def\tabu@message@target {^^J(tabu) Target specified:
1512
+ \the\tabu@target \on@line, page \the\c@page}
1513
+ \def\tabu@message@arith {\tabu@header
1514
+ \tabu@msgalign \tabucolX { }{ }{ }{ }{ }\@@
1515
+ \tabu@msgalign \wd\tabu@box { }{ }{ }{ }{ }\@@
1516
+ \tabu@msgalign \tabu@target { }{ }{ }{ }{ }\@@
1517
+ \tabu@msgalign@PT \dimen@ { }{}{}{}{}{}{}\@@
1518
+ \ifdim \tabu@DELTA<\tabu@hfuzz giving space\else
1519
+ \tabu@msgalign \dimexpr (\@tempdima-\tabu@DELTA) *\p@/\tabu@Xsum -\tabucolX {}{}{}{}{}\@@
1520
+ \fi
1521
+ }% \tabu@message@arith
1522
+ \def\tabu@message@spreadarith {\tabu@spreadheader
1523
+ \tabu@msgalign \tabu@spreadtarget { }{ }{ }{ }{}\@@
1524
+ \tabu@msgalign \wd\tabu@box { }{ }{ }{ }{}\@@
1525
+ \tabu@msgalign -\tabu@naturalXmax { }{}{}{}{}\@@
1526
+ \tabu@msgalign \tabu@naturalXmin { }{ }{ }{ }{}\@@
1527
+ \tabu@msgalign \ifdim \dimexpr\@tempdimc>\tabu@target \tabu@target
1528
+ \else \@tempdimc+\tabu@spreadtarget \fi
1529
+ {}{}{}{}{}\@@}
1530
+ \def\tabu@message@negcoef #1#2{
1531
+ \tabu@spaces\tabu@spaces\space * #1. X[\rem@pt#2]:
1532
+ \space width = \tabu@wd {#1}
1533
+ \expandafter\string\csname tabu@\the\tabu@nested.W\number#1\endcsname
1534
+ \ifdim -\tabu@pt#2\tabucolX<\tabu@target
1535
+ < \number-\rem@pt#2 X
1536
+ = \the\dimexpr -\tabu@pt#2\tabucolX \relax
1537
+ \else
1538
+ <= \the\tabu@target\space < \number-\rem@pt#2 X\fi}
1539
+ \def\tabu@message@reached{\tabu@header
1540
+ ******* Reached Target:
1541
+ hfuzz = \tabu@hfuzz\on@line\space *******}
1542
+ \def\tabu@message@etime{\edef\tabu@stoptime{\the\pdfelapsedtime}%
1543
+ \tabu@message{(tabu)\tabu@spaces Time elapsed during measure:
1544
+ \the\numexpr(\tabu@stoptime-\tabu@starttime-32767)/65536\relax sec
1545
+ \the\numexpr\numexpr(\tabu@stoptime-\tabu@starttime)
1546
+ -\numexpr(\tabu@stoptime-\tabu@starttime-32767)/65536\relax*65536\relax
1547
+ *1000/65536\relax ms \tabu@spaces(\the\tabu@cnt\space
1548
+ cycle\ifnum\tabu@cnt>\@ne s\fi)^^J^^J}}
1549
+ \def\tabu@message@verticalsp {%
1550
+ \ifdim \@tempdima>\tabu@ht
1551
+ \ifdim \@tempdimb>\tabu@dp
1552
+ \expandafter\expandafter\expandafter\string\tabu@ht =
1553
+ \tabu@msgalign \@tempdima { }{ }{ }{ }{ }\@@
1554
+ \expandafter\expandafter\expandafter\string\tabu@dp =
1555
+ \tabu@msgalign \@tempdimb { }{ }{ }{ }{ }\@@^^J%
1556
+ \else
1557
+ \expandafter\expandafter\expandafter\string\tabu@ht =
1558
+ \tabu@msgalign \@tempdima { }{ }{ }{ }{ }\@@^^J%
1559
+ \fi
1560
+ \else\ifdim \@tempdimb>\tabu@dp
1561
+ \tabu@spaces\tabu@spaces\tabu@spaces
1562
+ \expandafter\expandafter\expandafter\string\tabu@dp =
1563
+ \tabu@msgalign \@tempdimb { }{ }{ }{ }{ }\@@^^J\fi
1564
+ \fi
1565
+ }% \tabu@message@verticalsp
1566
+ \edef\tabu@spaces{\@spaces}
1567
+ \def\tabu@strippt{\expandafter\tabu@pt\the}
1568
+ {\@makeother\P \@makeother\T\lowercase{\gdef\tabu@pt #1PT{#1}}}
1569
+ \def\tabu@msgalign{\expandafter\tabu@msg@align\the\dimexpr}
1570
+ \def\tabu@msgalign@PT{\expandafter\tabu@msg@align\romannumeral-`\0\tabu@strippt}
1571
+ \def\do #1{%
1572
+ \def\tabu@msg@align##1.##2##3##4##5##6##7##8##9\@@{%
1573
+ \ifnum##1<10 #1 #1\else
1574
+ \ifnum##1<100 #1 \else
1575
+ \ifnum##1<\@m #1\fi\fi\fi
1576
+ ##1.##2##3##4##5##6##7##8#1}%
1577
+ \def\tabu@header{(tabu) \ifnum\tabu@cnt<10 #1\fi\the\tabu@cnt) }%
1578
+ \def\tabu@titles{\ifnum \tabu@nested=\z@
1579
+ (tabu) Try#1 #1 tabu X #1 #1 #1tabu Width #1 #1 Target
1580
+ #1 #1 #1 Coefs #1 #1 #1 Update^^J\fi}%
1581
+ \def\tabu@spreadheader{%
1582
+ (tabu) Try#1 #1 Spread #1 #1 tabu Width #1 #1 #1 Nat. X #1 #1 #1 #1Nat. Min.
1583
+ #1 New Target^^J%
1584
+ (tabu) sprd}
1585
+ \def\tabu@message@save {\begingroup
1586
+ \def\x ####1{\tabu@msg@align ####1{ }{ }{ }{ }{}\@@}
1587
+ \def\z ####1{\expandafter\x\expandafter{\romannumeral-`\0\tabu@strippt
1588
+ \dimexpr####1\p@{ }{ }}}%
1589
+ \let\color \relax \def\tabu@rulesstyle ####1####2{\detokenize{####1}}%
1590
+ \let\CT@arc@ \relax \let\@preamble \@gobble
1591
+ \let\tabu@savedpream \@firstofone
1592
+ \let\tabu@savedparams \@firstofone
1593
+ \def\tabu@target ####1\relax {(tabu) target #1 #1 #1 #1 #1 = \x{####1}^^J}%
1594
+ \def\tabucolX ####1\relax {(tabu) X columns width#1 = \x{####1}^^J}%
1595
+ \def\tabu@nbcols ####1\relax {(tabu) Number of columns: \z{####1}^^J}%
1596
+ \def\tabu@aligndefault ####1{(tabu) Default alignment: #1 #1 ####1^^J}%
1597
+ \def\col@sep ####1\relax {(tabu) column sep #1 #1 #1 = \x{####1}^^J}%
1598
+ \def\arrayrulewidth ####1\relax{(tabu) arrayrulewidth #1 = \x{####1}}%
1599
+ \def\doublerulesep ####1\relax { doublerulesep = \x{####1}^^J}%
1600
+ \def\extratabsurround####1\relax{(tabu) extratabsurround = \x{####1}^^J}%
1601
+ \def\extrarowheight ####1\relax{(tabu) extrarowheight #1 = \x{####1}}%
1602
+ \def\extrarowdepth ####1\relax {extrarowdepth = \x{####1}^^J}%
1603
+ \def\abovetabulinesep####1\relax{(tabu) abovetabulinesep=\x{####1} }%
1604
+ \def\belowtabulinesep####1\relax{ belowtabulinesep=\x{####1}^^J}%
1605
+ \def\arraystretch ####1{(tabu) arraystretch #1 #1 = \z{####1}^^J}%
1606
+ \def\minrowclearance####1\relax{(tabu) minrowclearance #1 = \x{####1}^^J}%
1607
+ \def\tabu@arc@L ####1{(tabu) taburulecolor #1 #1 = ####1^^J}%
1608
+ \def\tabu@drsc@L ####1{(tabu) tabudoublerulecolor= ####1^^J}%
1609
+ \def\tabu@evr@L ####1{(tabu) everyrow #1 #1 #1 #1 = \detokenize{####1}^^J}%
1610
+ \def\tabu@ls@L ####1{(tabu) line style = \detokenize{####1}^^J}%
1611
+ \def\NC@find ####1\@nil{(tabu) tabu preamble#1 #1 = \detokenize{####1}^^J}%
1612
+ \def\tabu@wddef####1####2{(tabu) Natural width ####1 = \x{####2}^^J}%
1613
+ \let\edef \@gobbletwo \let\def \@empty \let\let \@gobbletwo
1614
+ \tabu@message{%
1615
+ (tabu) \string\savetabu{\tabu@temp}: \on@line^^J%
1616
+ \tabu@usetabu \@nil^^J}%
1617
+ \endgroup}
1618
+ }\do{ }
1619
+ %% Measuring the natural width (varwidth) - store the results -------
1620
+ \def\tabu@startpboxmeasure #1{\bgroup % entering \vtop
1621
+ \edef\tabu@temp{\expandafter\@secondoftwo \ifx\tabu@hsize #1\else\relax\fi}%
1622
+ \ifodd 1\ifx \tabu@temp\@empty 0 \else % starts with \tabu@hsize ?
1623
+ \iftabu@spread \else % if spread -> measure
1624
+ \ifdim \tabu@temp\p@>\z@ 0 \fi\fi\fi% if coef>0 -> do not measure
1625
+ \let\@startpbox \tabu@startpboxORI % restore immediately (nesting)
1626
+ \tabu@measuringtrue % for the quick option...
1627
+ \tabu@Xcol =\expandafter\@firstoftwo\ifx\tabu@hsize #1\fi
1628
+ \ifdim \tabu@temp\p@>\z@ \ifdim \tabu@temp\tabucolX<\tabu@target
1629
+ \tabu@target=\tabu@temp\tabucolX \fi\fi
1630
+ \setbox\tabu@box \hbox \bgroup
1631
+ \begin{varwidth}\tabu@target
1632
+ \let\FV@ListProcessLine \tabu@FV@ListProcessLine % \hbox to natural width...
1633
+ \narrowragged \arraybackslash \parfillskip \@flushglue
1634
+ \ifdefined\pdfadjustspacing \pdfadjustspacing\z@ \fi
1635
+ \bgroup \aftergroup\tabu@endpboxmeasure
1636
+ \ifdefined \cellspacetoplimit \tabu@cellspacepatch \fi
1637
+ \else \expandafter\@gobble
1638
+ \tabu@startpboxquick{#1}% \@gobble \bgroup
1639
+ \fi
1640
+ }% \tabu@startpboxmeasure
1641
+ \def\tabu@cellspacepatch{\def\bcolumn##1\@nil{}\let\ecolumn\@empty
1642
+ \bgroup\color@begingroup}
1643
+ \def\tabu@endpboxmeasure {%
1644
+ \@finalstrut \@arstrutbox
1645
+ \end{varwidth}\egroup % <got my \tabu@box>
1646
+ \ifdim \tabu@temp\p@ <\z@ % neg coef
1647
+ \ifdim \tabu@wd\tabu@Xcol <\wd\tabu@box
1648
+ \tabu@wddef\tabu@Xcol {\the\wd\tabu@box}%
1649
+ \tabu@debug{\tabu@message@endpboxmeasure}%
1650
+ \fi
1651
+ \else % spread coef>0
1652
+ \global\advance \tabu@naturalX \wd\tabu@box
1653
+ \@tempdima =\dimexpr \wd\tabu@box *\p@/\dimexpr \tabu@temp\p@\relax \relax
1654
+ \ifdim \tabu@naturalXmax <\tabu@naturalX
1655
+ \xdef\tabu@naturalXmax {\the\tabu@naturalX}\fi
1656
+ \ifdim \tabu@naturalXmin <\@tempdima
1657
+ \xdef\tabu@naturalXmin {\the\@tempdima}\fi
1658
+ \fi
1659
+ \box\tabu@box \egroup % end of \vtop (measure) restore \tabu@target
1660
+ }% \tabu@endpboxmeasure
1661
+ \def\tabu@wddef #1{\expandafter\xdef
1662
+ \csname tabu@\the\tabu@nested.W\number#1\endcsname}
1663
+ \def\tabu@wd #1{\csname tabu@\the\tabu@nested.W\number#1\endcsname}
1664
+ \def\tabu@message@endpboxmeasure{\tabu@spaces\tabu@spaces<-> % <-> save natural wd
1665
+ \the\tabu@Xcol. X[\tabu@temp]:
1666
+ target = \the\tabucolX \space
1667
+ \expandafter\expandafter\expandafter\string\tabu@wd\tabu@Xcol
1668
+ =\tabu@wd\tabu@Xcol
1669
+ }% \tabu@message@endpboxmeasure
1670
+ \def\tabu@startpboxquick {\bgroup
1671
+ \let\@startpbox \tabu@startpboxORI % restore immediately
1672
+ \let\tabu \tabu@quick % \begin is expanded before...
1673
+ \expandafter\@gobble \@startpbox % gobbles \bgroup
1674
+ }% \tabu@startpboxquick
1675
+ \def\tabu@quick {\begingroup \iffalse{\fi \ifnum0=`}\fi
1676
+ \toks@{}\def\tabu@stack{b}\tabu@collectbody \tabu@endquick
1677
+ }% \tabu@quick
1678
+ \def\tabu@endquick {%
1679
+ \ifodd 1\ifx\tabu@end@envir\tabu@endtabu \else
1680
+ \ifx\tabu@end@envir\tabu@endtabus \else 0\fi\fi\relax
1681
+ \endgroup
1682
+ \else \let\endtabu \relax
1683
+ \tabu@end@envir
1684
+ \fi
1685
+ }% \tabu@quick
1686
+ \def\tabu@endtabu {\end{tabu}}
1687
+ \def\tabu@endtabus {\end{tabu*}}
1688
+ %% Measuring the heights and depths - store the results -------------
1689
+ \def\tabu@verticalmeasure{\everypar{}%
1690
+ \ifnum \currentgrouptype>12 % 14=semi-simple, 15=math shift group
1691
+ \setbox\tabu@box =\hbox\bgroup
1692
+ \let\tabu@verticalspacing \tabu@verticalsp@lcr
1693
+ \d@llarbegin % after \hbox ...
1694
+ \else
1695
+ \edef\tabu@temp{\ifnum\currentgrouptype=5\vtop
1696
+ \else\ifnum\currentgrouptype=12\vcenter
1697
+ \else\vbox\fi\fi}%
1698
+ \setbox\tabu@box \hbox\bgroup$\tabu@temp \bgroup
1699
+ \let\tabu@verticalspacing \tabu@verticalsp@pmb
1700
+ \fi
1701
+ }% \tabu@verticalmeasure
1702
+ \def\tabu@verticalsp@lcr{%
1703
+ \d@llarend \egroup % <got my \tabu@box>
1704
+ \@tempdima \dimexpr \ht\tabu@box+\abovetabulinesep
1705
+ \@tempdimb \dimexpr \dp\tabu@box+\belowtabulinesep \relax
1706
+ \ifdim\tabustrutrule>\z@ \tabu@debug{\tabu@message@verticalsp}\fi
1707
+ \ifdim \tabu@ht<\@tempdima \tabu@htdef{\the\@tempdima}\fi
1708
+ \ifdim \tabu@dp<\@tempdimb \tabu@dpdef{\the\@tempdimb}\fi
1709
+ \noindent\vrule height\@tempdima depth\@tempdimb
1710
+ }% \tabu@verticalsp@lcr
1711
+ \def\tabu@verticalsp@pmb{% inserts struts as needed
1712
+ \par \expandafter\egroup
1713
+ \expandafter$\expandafter
1714
+ \egroup \expandafter
1715
+ \@tempdimc \the\prevdepth
1716
+ \@tempdima \dimexpr \ht\tabu@box+\abovetabulinesep
1717
+ \@tempdimb \dimexpr \dp\tabu@box+\belowtabulinesep \relax
1718
+ \ifdim\tabustrutrule>\z@ \tabu@debug{\tabu@message@verticalsp}\fi
1719
+ \ifdim \tabu@ht<\@tempdima \tabu@htdef{\the\@tempdima}\fi
1720
+ \ifdim \tabu@dp<\@tempdimb \tabu@dpdef{\the\@tempdimb}\fi
1721
+ \let\@finalstrut \@gobble
1722
+ \hrule height\@tempdima depth\@tempdimb width\hsize
1723
+ %% \box\tabu@box
1724
+ }% \tabu@verticalsp@pmb
1725
+
1726
+ \def\tabu@verticalinit{%
1727
+ \ifnum \c@taburow=\z@ \tabu@rearstrut \fi % after \tabu@reset !
1728
+ \advance\c@taburow \@ne
1729
+ \tabu@htdef{\the\ht\@arstrutbox}\tabu@dpdef{\the\dp\@arstrutbox}%
1730
+ \advance\c@taburow \m@ne
1731
+ }% \tabu@verticalinit
1732
+ \def\tabu@htdef {\expandafter\xdef \csname tabu@\the\tabu@nested.H\the\c@taburow\endcsname}
1733
+ \def\tabu@ht {\csname tabu@\the\tabu@nested.H\the\c@taburow\endcsname}
1734
+ \def\tabu@dpdef {\expandafter\xdef \csname tabu@\the\tabu@nested.D\the\c@taburow\endcsname}
1735
+ \def\tabu@dp {\csname tabu@\the\tabu@nested.D\the\c@taburow\endcsname}
1736
+ \def\tabu@verticaldynamicadjustment {%
1737
+ \advance\c@taburow \@ne
1738
+ \extrarowheight \dimexpr\tabu@ht - \ht\strutbox
1739
+ \extrarowdepth \dimexpr\tabu@dp - \dp\strutbox
1740
+ \let\arraystretch \@empty
1741
+ \advance\c@taburow \m@ne
1742
+ }% \tabu@verticaldynamicadjustment
1743
+ \def\tabuphantomline{\crcr \noalign{%
1744
+ {\globaldefs \@ne
1745
+ \setbox\@arstrutbox \box\voidb@x
1746
+ \let\tabu@@celllalign \tabu@celllalign
1747
+ \let\tabu@@cellralign \tabu@cellralign
1748
+ \let\tabu@@cellleft \tabu@cellleft
1749
+ \let\tabu@@cellright \tabu@cellright
1750
+ \let\tabu@@thevline \tabu@thevline
1751
+ \let\tabu@celllalign \@empty
1752
+ \let\tabu@cellralign \@empty
1753
+ \let\tabu@cellright \@empty
1754
+ \let\tabu@cellleft \@empty
1755
+ \let\tabu@thevline \relax}%
1756
+ \edef\tabu@temp{\tabu@multispan \tabu@nbcols{\noindent &}}%
1757
+ \toks@\expandafter{\tabu@temp \noindent\tabu@everyrowfalse \cr
1758
+ \noalign{\tabu@rearstrut
1759
+ {\globaldefs\@ne
1760
+ \let\tabu@celllalign \tabu@@celllalign
1761
+ \let\tabu@cellralign \tabu@@cellralign
1762
+ \let\tabu@cellleft \tabu@@cellleft
1763
+ \let\tabu@cellright \tabu@@cellright
1764
+ \let\tabu@thevline \tabu@@thevline}}}%
1765
+ \expandafter}\the\toks@
1766
+ }% \tabuphantomline
1767
+ %% \firsthline and \lasthline corrections ---------------------------
1768
+ \def\tabu@firstline {\tabu@hlineAZ \tabu@firsthlinecorrection {}}
1769
+ \def\tabu@firsthline{\tabu@hlineAZ \tabu@firsthlinecorrection \hline}
1770
+ \def\tabu@lastline {\tabu@hlineAZ \tabu@lasthlinecorrection {}}
1771
+ \def\tabu@lasthline {\tabu@hlineAZ \tabu@lasthlinecorrection \hline}
1772
+ \def\tabu@hline {% replaces \hline if no colortbl (see \AtBeginDocument)
1773
+ \noalign{\ifnum0=`}\fi
1774
+ {\CT@arc@\hrule height\arrayrulewidth}%
1775
+ \futurelet \tabu@temp \tabu@xhline
1776
+ }% \tabu@hline
1777
+ \def\tabu@xhline{%
1778
+ \ifx \tabu@temp \hline
1779
+ {\ifx \CT@drsc@\relax \vskip
1780
+ \else\ifx \CT@drsc@\@empty \vskip
1781
+ \else \CT@drsc@\hrule height
1782
+ \fi\fi
1783
+ \doublerulesep}%
1784
+ \fi
1785
+ \ifnum0=`{\fi}%
1786
+ }% \tabu@xhline
1787
+ \def\tabu@hlineAZ #1#2{\noalign{\ifnum0=`}\fi \dimen@ \z@ \count@ \z@
1788
+ \toks@{}\def\tabu@hlinecorrection{#1}\def\tabu@temp{#2}%
1789
+ \tabu@hlineAZsurround
1790
+ }% \tabu@hlineAZ
1791
+ \newcommand*\tabu@hlineAZsurround[1][\extratabsurround]{%
1792
+ \extratabsurround #1\let\tabucline \tabucline@scan
1793
+ \let\hline \tabu@hlinescan \let\firsthline \hline
1794
+ \let\cline \tabu@clinescan \let\lasthline \hline
1795
+ \expandafter \futurelet \expandafter \tabu@temp
1796
+ \expandafter \tabu@nexthlineAZ \tabu@temp
1797
+ }% \tabu@hlineAZsurround
1798
+ \def\tabu@hlinescan {\tabu@thick \arrayrulewidth \tabu@xhlineAZ \hline}
1799
+ \def\tabu@clinescan #1{\tabu@thick \arrayrulewidth \tabu@xhlineAZ {\cline{#1}}}
1800
+ \def\tabucline@scan{\@testopt \tabucline@sc@n {}}
1801
+ \def\tabucline@sc@n #1[#2]{\tabu@xhlineAZ {\tabucline[{#1}]{#2}}}
1802
+ \def\tabu@nexthlineAZ{%
1803
+ \ifx \tabu@temp\hline \else
1804
+ \ifx \tabu@temp\cline \else
1805
+ \ifx \tabu@temp\tabucline \else
1806
+ \tabu@hlinecorrection
1807
+ \fi\fi\fi
1808
+ }% \tabu@nexthlineAZ
1809
+ \def\tabu@xhlineAZ #1{%
1810
+ \toks@\expandafter{\the\toks@ #1}%
1811
+ \@tempdimc \tabu@thick % The last line width
1812
+ \ifcase\count@ \@tempdimb \tabu@thick % The first line width
1813
+ \else \advance\dimen@ \dimexpr \tabu@thick+\doublerulesep \relax
1814
+ \fi
1815
+ \advance\count@ \@ne \futurelet \tabu@temp \tabu@nexthlineAZ
1816
+ }% \tabu@xhlineAZ
1817
+ \def\tabu@firsthlinecorrection{% \count@ = number of \hline -1
1818
+ \@tempdima \dimexpr \ht\@arstrutbox+\dimen@
1819
+ \edef\firsthline{% <local in \noalign>
1820
+ \omit \hbox to\z@{\hss{\noexpand\tabu@DBG{yellow}\vrule
1821
+ height \the\dimexpr\@tempdima+\extratabsurround
1822
+ depth \dp\@arstrutbox
1823
+ width \tabustrutrule}\hss}\cr
1824
+ \noalign{\vskip -\the\dimexpr \@tempdima+\@tempdimb
1825
+ +\dp\@arstrutbox \relax}%
1826
+ \the\toks@
1827
+ }\ifnum0=`{\fi
1828
+ \expandafter}\firsthline % we are then !
1829
+ }% \tabu@firsthlinecorrection
1830
+ \def\tabu@lasthlinecorrection{%
1831
+ \@tempdima \dimexpr \dp\@arstrutbox+\dimen@+\@tempdimb+\@tempdimc
1832
+ \edef\lasthline{% <local in \noalign>
1833
+ \the\toks@
1834
+ \noalign{\vskip -\the\dimexpr\dimen@+\@tempdimb+\dp\@arstrutbox}%
1835
+ \omit \hbox to\z@{\hss{\noexpand\tabu@DBG{yellow}\vrule
1836
+ depth \the\dimexpr \dp\@arstrutbox+\@tempdimb+\dimen@
1837
+ +\extratabsurround-\@tempdimc
1838
+ height \z@
1839
+ width \tabustrutrule}\hss}\cr
1840
+ }\ifnum0=`{\fi
1841
+ \expandafter}\lasthline % we are then !
1842
+ }% \tabu@lasthlinecorrection
1843
+ \def\tabu@LT@@hline{%
1844
+ \ifx\LT@next\hline
1845
+ \global\let\LT@next \@gobble
1846
+ \ifx \CT@drsc@\relax
1847
+ \gdef\CT@LT@sep{%
1848
+ \noalign{\penalty-\@medpenalty\vskip\doublerulesep}}%
1849
+ \else
1850
+ \gdef\CT@LT@sep{%
1851
+ \multispan\LT@cols{%
1852
+ \CT@drsc@\leaders\hrule\@height\doublerulesep\hfill}\cr}%
1853
+ \fi
1854
+ \else
1855
+ \global\let\LT@next\empty
1856
+ \gdef\CT@LT@sep{%
1857
+ \noalign{\penalty-\@lowpenalty\vskip-\arrayrulewidth}}%
1858
+ \fi
1859
+ \ifnum0=`{\fi}%
1860
+ \multispan\LT@cols
1861
+ {\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfill}\cr
1862
+ \CT@LT@sep
1863
+ \multispan\LT@cols
1864
+ {\CT@arc@\leaders\hrule\@height\arrayrulewidth\hfill}\cr
1865
+ \noalign{\penalty\@M}%
1866
+ \LT@next
1867
+ }% \tabu@LT@@hline
1868
+ %% Horizontal lines : \tabucline ------------------------------------
1869
+ \let\tabu@start \@tempcnta
1870
+ \let\tabu@stop \@tempcntb
1871
+ \newcommand*\tabucline{\noalign{\ifnum0=`}\fi \tabu@cline}
1872
+ \newcommand*\tabu@cline[2][]{\tabu@startstop{#2}%
1873
+ \ifnum \tabu@stop<\z@ \toks@{}%
1874
+ \else \tabu@clinearg{#1}\tabu@thestyle
1875
+ \edef\tabucline{\toks@{%
1876
+ \ifnum \tabu@start>\z@ \omit
1877
+ \tabu@multispan\tabu@start {\span\omit}&\fi
1878
+ \omit \tabu@multispan\tabu@stop {\span\omit}%
1879
+ \tabu@thehline\cr
1880
+ }}\tabucline
1881
+ \tabu@tracinglines{(tabu:tabucline) Style: #1^^J\the\toks@^^J^^J}%
1882
+ \fi
1883
+ \futurelet \tabu@temp \tabu@xcline
1884
+ }% \tabu@cline
1885
+ \def\tabu@clinearg #1{%
1886
+ \ifx\\#1\\\let\tabu@thestyle \tabu@ls@
1887
+ \else \@defaultunits \expandafter\let\expandafter\@tempa
1888
+ \romannumeral-`\0#1\relax \@nnil
1889
+ \ifx \hbox\@tempa \tabu@clinebox{#1}%
1890
+ \else\ifx \box\@tempa \tabu@clinebox{#1}%
1891
+ \else\ifx \vbox\@tempa \tabu@clinebox{#1}%
1892
+ \else\ifx \vtop\@tempa \tabu@clinebox{#1}%
1893
+ \else\ifx \copy\@tempa \tabu@clinebox{#1}%
1894
+ \else\ifx \leaders\@tempa \tabu@clineleads{#1}%
1895
+ \else\ifx \cleaders\@tempa \tabu@clineleads{#1}%
1896
+ \else\ifx \xleaders\@tempa \tabu@clineleads{#1}%
1897
+ \else\tabu@getline {#1}%
1898
+ \fi\fi\fi\fi\fi\fi\fi\fi
1899
+ \fi
1900
+ }% \tabu@clinearg
1901
+ \def\tabu@clinebox #1{\tabu@clineleads{\xleaders#1\hss}}
1902
+ \def\tabu@clineleads #1{%
1903
+ \let\tabu@thestyle \relax \let\tabu@leaders \@undefined
1904
+ \gdef\tabu@thehrule{#1}}
1905
+ \def\tabu@thehline{\begingroup
1906
+ \ifdefined\tabu@leaders
1907
+ \noexpand\tabu@thehleaders
1908
+ \else \noexpand\tabu@thehrule
1909
+ \fi \endgroup
1910
+ }% \tabu@thehline
1911
+ \def\tabu@xcline{%
1912
+ \ifx \tabu@temp\tabucline
1913
+ \toks@\expandafter{\the\toks@ \noalign
1914
+ {\ifx\CT@drsc@\relax \vskip
1915
+ \else \CT@drsc@\hrule height
1916
+ \fi
1917
+ \doublerulesep}}%
1918
+ \fi
1919
+ \tabu@docline
1920
+ }% \tabu@xcline
1921
+ \def\tabu@docline {\ifnum0=`{\fi \expandafter}\the\toks@}
1922
+ \def\tabu@docline@evr {\xdef\tabu@doclineafter{\the\toks@}%
1923
+ \ifnum0=`{\fi}\aftergroup\tabu@doclineafter}
1924
+ \def\tabu@multispan #1#2{%
1925
+ \ifnum\numexpr#1>\@ne #2\expandafter\tabu@multispan
1926
+ \else \expandafter\@gobbletwo
1927
+ \fi {#1-1}{#2}%
1928
+ }% \tabu@multispan
1929
+ \def\tabu@startstop #1{\tabu@start@stop #1\relax 1-\tabu@nbcols \@nnil}
1930
+ \def\tabu@start@stop #1-#2\@nnil{%
1931
+ \@defaultunits \tabu@start\number 0#1\relax \@nnil
1932
+ \@defaultunits \tabu@stop \number 0#2\relax \@nnil
1933
+ \tabu@stop \ifnum \tabu@start>\tabu@nbcols \m@ne
1934
+ \else\ifnum \tabu@stop=\z@ \tabu@nbcols
1935
+ \else\ifnum \tabu@stop>\tabu@nbcols \tabu@nbcols
1936
+ \else \tabu@stop
1937
+ \fi\fi\fi
1938
+ \advance\tabu@start \m@ne
1939
+ \ifnum \tabu@start>\z@ \advance\tabu@stop -\tabu@start \fi
1940
+ }% \tabu@start@stop
1941
+ %% Numbers: siunitx S columns (and \tabudecimal) -------------------
1942
+ \def\tabu@tabudecimal #1{%
1943
+ \def\tabu@decimal{#1}\@temptokena{}%
1944
+ \let\tabu@getdecimal@ \tabu@getdecimal@ignorespaces
1945
+ \tabu@scandecimal
1946
+ }% \tabu@tabudecimal
1947
+ \def\tabu@scandecimal{\futurelet \tabu@temp \tabu@getdecimal@}
1948
+ \def\tabu@skipdecimal#1{#1\tabu@scandecimal}
1949
+ \def\tabu@getdecimal@ignorespaces{%
1950
+ \ifcase 0\ifx\tabu@temp\ignorespaces\else
1951
+ \ifx\tabu@temp\@sptoken1\else
1952
+ 2\fi\fi\relax
1953
+ \let\tabu@getdecimal@ \tabu@getdecimal
1954
+ \expandafter\tabu@skipdecimal
1955
+ \or \expandafter\tabu@gobblespace\expandafter\tabu@scandecimal
1956
+ \else \expandafter\tabu@skipdecimal
1957
+ \fi
1958
+ }% \tabu@getdecimal@ignorespaces
1959
+ \def\tabu@get@decimal#1{\@temptokena\expandafter{\the\@temptokena #1}%
1960
+ \tabu@scandecimal}
1961
+ \def\do#1{%
1962
+ \def\tabu@get@decimalspace#1{%
1963
+ \@temptokena\expandafter{\the\@temptokena #1}\tabu@scandecimal}%
1964
+ }\do{ }
1965
+ \let\tabu@@tabudecimal \tabu@tabudecimal
1966
+ \def\tabu@getdecimal{%
1967
+ \ifcase 0\ifx 0\tabu@temp\else
1968
+ \ifx 1\tabu@temp\else
1969
+ \ifx 2\tabu@temp\else
1970
+ \ifx 3\tabu@temp\else
1971
+ \ifx 4\tabu@temp\else
1972
+ \ifx 5\tabu@temp\else
1973
+ \ifx 6\tabu@temp\else
1974
+ \ifx 7\tabu@temp\else
1975
+ \ifx 8\tabu@temp\else
1976
+ \ifx 9\tabu@temp\else
1977
+ \ifx .\tabu@temp\else
1978
+ \ifx ,\tabu@temp\else
1979
+ \ifx -\tabu@temp\else
1980
+ \ifx +\tabu@temp\else
1981
+ \ifx e\tabu@temp\else
1982
+ \ifx E\tabu@temp\else
1983
+ \ifx\tabu@cellleft\tabu@temp1\else
1984
+ \ifx\ignorespaces\tabu@temp1\else
1985
+ \ifx\@sptoken\tabu@temp2\else
1986
+ 3\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\relax
1987
+ \expandafter\tabu@get@decimal
1988
+ \or \expandafter\tabu@skipdecimal
1989
+ \or \expandafter\tabu@get@decimalspace
1990
+ \else\expandafter\tabu@printdecimal
1991
+ \fi
1992
+ }% \tabu@getdecimal
1993
+ \def\tabu@printdecimal{%
1994
+ \edef\tabu@temp{\the\@temptokena}%
1995
+ \ifx\tabu@temp\@empty\else
1996
+ \ifx\tabu@temp\space\else
1997
+ \expandafter\tabu@decimal\expandafter{\the\@temptokena}%
1998
+ \fi\fi
1999
+ }% \tabu@printdecimal
2000
+ %% Verbatim inside X columns ----------------------------------------
2001
+ \def\tabu@verbatim{%
2002
+ \let\verb \tabu@verb
2003
+ \let\FV@DefineCheckEnd \tabu@FV@DefineCheckEnd
2004
+ }% \tabu@verbatim
2005
+ \let\tabu@ltx@verb \verb
2006
+ \def\tabu@verb{\@ifstar {\tabu@ltx@verb*} \tabu@ltx@verb}
2007
+ \def\tabu@fancyvrb {%
2008
+ \def\tabu@FV@DefineCheckEnd ##1{%
2009
+ \def\tabu@FV@DefineCheckEnd{%
2010
+ ##1% <original definition (if fancyvrb is loaded)>
2011
+ \let\FV@CheckEnd \tabu@FV@CheckEnd
2012
+ \let\FV@@CheckEnd \tabu@FV@@CheckEnd
2013
+ \let\FV@@@CheckEnd \tabu@FV@@@CheckEnd
2014
+ \edef\FV@EndScanning{%
2015
+ \def\noexpand\next{\noexpand\end{\FV@EnvironName}}%
2016
+ \global\let\noexpand\FV@EnvironName\relax
2017
+ \noexpand\next}%
2018
+ \xdef\FV@EnvironName{\detokenize\expandafter{\FV@EnvironName}}}%
2019
+ }\expandafter\tabu@FV@DefineCheckEnd\expandafter{\FV@DefineCheckEnd}
2020
+ }% \tabu@fancyvrb
2021
+ \def\tabu@FV@CheckEnd #1{\expandafter\FV@@CheckEnd \detokenize{#1\end{}}\@nil}
2022
+ \edef\tabu@FV@@@CheckEnd {\detokenize{\end{}}}
2023
+ \begingroup
2024
+ \catcode`\[1 \catcode`\]2
2025
+ \@makeother\{ \@makeother\}
2026
+ \edef\x[\endgroup
2027
+ \def\noexpand\tabu@FV@@CheckEnd ##1\detokenize[\end{]##2\detokenize[}]##3%
2028
+ ]\x \@nil{\def\@tempa{#2}\def\@tempb{#3}}
2029
+ \def\tabu@FV@ListProcessLine #1{%
2030
+ \hbox {%to \hsize{%
2031
+ \kern\leftmargin
2032
+ \hbox {%to \linewidth{%
2033
+ \FV@LeftListNumber
2034
+ \FV@LeftListFrame
2035
+ \FancyVerbFormatLine{#1}\hss
2036
+ %% DG/SR modification begin - Jan. 28, 1998 (for numbers=right add-on)
2037
+ %% \FV@RightListFrame}%
2038
+ \FV@RightListFrame
2039
+ \FV@RightListNumber}%
2040
+ %% DG/SR modification end
2041
+ \hss}}
2042
+ %% \savetabu --------------------------------------------------------
2043
+ \newcommand*\savetabu[1]{\noalign{%
2044
+ \tabu@sanitizearg{#1}\tabu@temp
2045
+ \ifx \tabu@temp\@empty \tabu@savewarn{}{The tabu will not be saved}\else
2046
+ \@ifundefined{tabu@saved@\tabu@temp}{}{\tabu@savewarn{#1}{Overwritting}}%
2047
+ \ifdefined\tabu@restored \expandafter\let
2048
+ \csname tabu@saved@\tabu@temp \endcsname \tabu@restored
2049
+ \else {\tabu@save}%
2050
+ \fi
2051
+ \fi}%
2052
+ }% \savetabu
2053
+ \def\tabu@save {%
2054
+ \toks0\expandafter{\tabu@saved@}%
2055
+ \iftabu@negcoef
2056
+ \let\tabu@wddef \relax \let\tabu@ \tabu@savewd \edef\tabu@savewd{\tabu@Xcoefs}%
2057
+ \toks0\expandafter{\the\toks\expandafter0\tabu@savewd}\fi
2058
+ \toks1\expandafter{\tabu@savedpream}%
2059
+ \toks2\expandafter{\tabu@savedpreamble}%
2060
+ \let\@preamble \relax
2061
+ \let\tabu@savedpream \relax \let\tabu@savedparams \relax
2062
+ \edef\tabu@preamble{%
2063
+ \def\noexpand\tabu@aligndefault{\tabu@align}%
2064
+ \def\tabu@savedparams {\noexpand\the\toks0}%
2065
+ \def\tabu@savedpream {\noexpand\the\toks1}}%
2066
+ \edef\tabu@usetabu{%
2067
+ \def\@preamble {\noexpand\the\toks2}%
2068
+ \tabu@target \the\tabu@target \relax
2069
+ \tabucolX \the\tabucolX \relax
2070
+ \tabu@nbcols \the\tabu@nbcols \relax
2071
+ \def\noexpand\tabu@aligndefault{\tabu@align}%
2072
+ \def\tabu@savedparams {\noexpand\the\toks0}%
2073
+ \def\tabu@savedpream {\noexpand\the\toks1}}%
2074
+ \let\tabu@aligndefault \relax \let\@sharp \relax
2075
+ \edef\@tempa{\noexpand\tabu@s@ved
2076
+ {\tabu@usetabu}
2077
+ {\tabu@preamble}
2078
+ {\the\toks1}}\@tempa
2079
+ \tabu@message@save
2080
+ }% \tabu@save
2081
+ \long\def\tabu@s@ved #1#2#3{%
2082
+ \def\tabu@usetabu{#1}% <for \tabu@message@save>
2083
+ \expandafter\gdef\csname tabu@saved@\tabu@temp\endcsname ##1{%
2084
+ \ifodd ##1% \usetabu
2085
+ \tabu@measuringfalse \tabu@spreadfalse % Just in case...
2086
+ \gdef\tabu@usetabu {%
2087
+ \ifdim \tabu@target>\z@ \tabu@warn@usetabu \fi
2088
+ \global\let\tabu@usetabu \@undefined
2089
+ \def\@halignto {to\tabu@target}%
2090
+ #1%
2091
+ \ifx \tabu@align\tabu@aligndefault@text
2092
+ \ifnum \tabu@nested=\z@
2093
+ \let\tabu@align \tabu@aligndefault \fi\fi}%
2094
+ \else % \preamble
2095
+ \gdef\tabu@preamble {%
2096
+ \global\let\tabu@preamble \@undefined
2097
+ #2%
2098
+ \ifx \tabu@align\tabu@aligndefault@text
2099
+ \ifnum \tabu@nested=\z@
2100
+ \let\tabu@align \tabu@aligndefault \fi\fi}%
2101
+ \fi
2102
+ #3}%
2103
+ }% \tabu@s@ved
2104
+ \def\tabu@aligndefault@text {\tabu@aligndefault}%
2105
+ \def\tabu@warn@usetabu {\PackageWarning{tabu}
2106
+ {Specifying a target with \string\usetabu\space is useless
2107
+ \MessageBreak The target cannot be changed!}}
2108
+ \def\tabu@savewd #1#2{\ifdim #2\p@<\z@ \tabu@wddef{#1}{\tabu@wd{#1}}\fi}
2109
+ \def\tabu@savewarn#1#2{\PackageInfo{tabu}
2110
+ {User-name `#1' already used for \string\savetabu
2111
+ \MessageBreak #2}}%
2112
+ \def\tabu@saveerr#1{\PackageError{tabu}
2113
+ {User-name `#1' is unknown for \string\usetabu
2114
+ \MessageBreak I cannot restore an unknown preamble!}\@ehd}
2115
+ %% \rowfont ---------------------------------------------------------
2116
+ \newskip \tabu@cellskip
2117
+ \def\tabu@rowfont{\ifdim \baselineskip=\z@\noalign\fi
2118
+ {\ifnum0=`}\fi \tabu@row@font}
2119
+ \newcommand*\tabu@row@font[2][]{%
2120
+ \ifnum7=\currentgrouptype
2121
+ \global\let\tabu@@cellleft \tabu@cellleft
2122
+ \global\let\tabu@@cellright \tabu@cellright
2123
+ \global\let\tabu@@celllalign \tabu@celllalign
2124
+ \global\let\tabu@@cellralign \tabu@cellralign
2125
+ \global\let\tabu@@rowfontreset\tabu@rowfontreset
2126
+ \fi
2127
+ \global\let\tabu@rowfontreset \tabu@rowfont@reset
2128
+ \expandafter\gdef\expandafter\tabu@cellleft\expandafter{\tabu@cellleft #2}%
2129
+ \ifcsname tabu@cell@#1\endcsname % row alignment
2130
+ \csname tabu@cell@#1\endcsname \fi
2131
+ \ifnum0=`{\fi}% end of group / noalign group
2132
+ }% \rowfont
2133
+ \def\tabu@ifcolorleavevmode #1{\let\color \tabu@leavevmodecolor #1\let\color\tabu@color}%
2134
+ \def\tabu@rowfont@reset{%
2135
+ \global\let\tabu@rowfontreset \tabu@@rowfontreset
2136
+ \global\let\tabu@cellleft \tabu@@cellleft
2137
+ \global\let\tabu@cellright \tabu@@cellright
2138
+ \global\let\tabu@cellfont \@empty
2139
+ \global\let\tabu@celllalign \tabu@@celllalign
2140
+ \global\let\tabu@cellralign \tabu@@cellralign
2141
+ }% \tabu@@rowfontreset
2142
+ \let\tabu@rowfontreset \@empty % overwritten \AtBeginDocument if colortbl
2143
+ %% \tabu@prepnext@tok -----------------------------------------------
2144
+ \newif \iftabu@cellright
2145
+ \def\tabu@prepnext@tok{%
2146
+ \ifnum \count@<\z@ % <first initialisation>
2147
+ \@tempcnta \@M % <not initialized by array.sty>
2148
+ \tabu@nbcols\z@
2149
+ \let\tabu@fornoopORI \@fornoop
2150
+ \tabu@cellrightfalse
2151
+ \else
2152
+ \ifcase \numexpr \count@-\@tempcnta \relax % (case 0): prev. token is left
2153
+ \advance \tabu@nbcols \@ne
2154
+ \iftabu@cellright % before-previous token is right and is finished
2155
+ \tabu@cellrightfalse % <only once>
2156
+ \tabu@righttok
2157
+ \fi
2158
+ \tabu@lefttok
2159
+ \or % (case 1) previous token is right
2160
+ \tabu@cellrighttrue \let\@fornoop \tabu@lastnoop
2161
+ \else % special column: do not change the token
2162
+ \iftabu@cellright % before-previous token is right
2163
+ \tabu@cellrightfalse
2164
+ \tabu@righttok
2165
+ \fi
2166
+ \fi % \ifcase
2167
+ \fi
2168
+ \tabu@prepnext@tokORI
2169
+ }% \tabu@prepnext@tok
2170
+ \long\def\tabu@lastnoop#1\@@#2#3{\tabu@lastn@@p #2\@nextchar \in@\in@@}
2171
+ \def\tabu@lastn@@p #1\@nextchar #2#3\in@@{%
2172
+ \ifx \in@#2\else
2173
+ \let\@fornoop \tabu@fornoopORI
2174
+ \xdef\tabu@mkpreambuffer{\tabu@nbcols\the\tabu@nbcols \tabu@mkpreambuffer}%
2175
+ \toks0\expandafter{\expandafter\tabu@everyrowtrue \the\toks0}%
2176
+ \expandafter\prepnext@tok
2177
+ \fi
2178
+ }% \tabu@lastnoop
2179
+ \def\tabu@righttok{%
2180
+ \advance \count@ \m@ne
2181
+ \toks\count@\expandafter {\the\toks\count@ \tabu@cellright \tabu@cellralign}%
2182
+ \advance \count@ \@ne
2183
+ }% \tabu@righttok
2184
+ \def\tabu@lefttok{\toks\count@\expandafter{\expandafter\tabu@celllalign
2185
+ \the\toks\count@ \tabu@cellleft}% after because of $
2186
+ }% \tabu@lefttok
2187
+ %% Neutralisation of glues ------------------------------------------
2188
+ \let\tabu@cellleft \@empty
2189
+ \let\tabu@cellright \@empty
2190
+ \tabu@celllalign@def{\tabu@cellleft}%
2191
+ \let\tabu@cellralign \@empty
2192
+ \def\tabu@cell@align #1#2#3{%
2193
+ \let\tabu@maybesiunitx \toks@ \tabu@celllalign
2194
+ \global \expandafter \tabu@celllalign@def \expandafter {\the\toks@ #1}%
2195
+ \toks@\expandafter{\tabu@cellralign #2}%
2196
+ \xdef\tabu@cellralign{\the\toks@}%
2197
+ \toks@\expandafter{\tabu@cellleft #3}%
2198
+ \xdef\tabu@cellleft{\the\toks@}%
2199
+ }% \tabu@cell@align
2200
+ \def\tabu@cell@l{% force alignment to left
2201
+ \tabu@cell@align
2202
+ {\tabu@removehfil \raggedright \tabu@cellleft}% left
2203
+ {\tabu@flush1\tabu@ignorehfil}% right
2204
+ \raggedright
2205
+ }% \tabu@cell@l
2206
+ \def\tabu@cell@c{% force alignment to center
2207
+ \tabu@cell@align
2208
+ {\tabu@removehfil \centering \tabu@flush{.5}\tabu@cellleft}
2209
+ {\tabu@flush{.5}\tabu@ignorehfil}
2210
+ \centering
2211
+ }% \tabu@cell@c
2212
+ \def\tabu@cell@r{% force alignment to right
2213
+ \tabu@cell@align
2214
+ {\tabu@removehfil \raggedleft \tabu@flush1\tabu@cellleft}
2215
+ \tabu@ignorehfil
2216
+ \raggedleft
2217
+ }% \tabu@cell@r
2218
+ \def\tabu@cell@j{% force justification (for p, m, b columns)
2219
+ \tabu@cell@align
2220
+ {\tabu@justify\tabu@cellleft}
2221
+ {}
2222
+ \tabu@justify
2223
+ }% \tabu@cell@j
2224
+ \def\tabu@justify{%
2225
+ \leftskip\z@skip \@rightskip\leftskip \rightskip\@rightskip
2226
+ \parfillskip\@flushglue
2227
+ }% \tabu@justify
2228
+ %% ragged2e settings
2229
+ \def\tabu@cell@L{% force alignment to left (ragged2e)
2230
+ \tabu@cell@align
2231
+ {\tabu@removehfil \RaggedRight \tabu@cellleft}
2232
+ {\tabu@flush 1\tabu@ignorehfil}
2233
+ \RaggedRight
2234
+ }% \tabu@cell@L
2235
+ \def\tabu@cell@C{% force alignment to center (ragged2e)
2236
+ \tabu@cell@align
2237
+ {\tabu@removehfil \Centering \tabu@flush{.5}\tabu@cellleft}
2238
+ {\tabu@flush{.5}\tabu@ignorehfil}
2239
+ \Centering
2240
+ }% \tabu@cell@C
2241
+ \def\tabu@cell@R{% force alignment to right (ragged2e)
2242
+ \tabu@cell@align
2243
+ {\tabu@removehfil \RaggedLeft \tabu@flush 1\tabu@cellleft}
2244
+ \tabu@ignorehfil
2245
+ \RaggedLeft
2246
+ }% \tabu@cell@R
2247
+ \def\tabu@cell@J{% force justification (ragged2e)
2248
+ \tabu@cell@align
2249
+ {\justifying \tabu@cellleft}
2250
+ {}
2251
+ \justifying
2252
+ }% \tabu@cell@J
2253
+ \def\tabu@flush#1{%
2254
+ \iftabu@colortbl % colortbl uses \hfill rather than \hfil
2255
+ \hskip \ifnum13<\currentgrouptype \stretch{#1}%
2256
+ \else \ifdim#1pt<\p@ \tabu@cellskip
2257
+ \else \stretch{#1}
2258
+ \fi\fi \relax
2259
+ \else % array.sty
2260
+ \ifnum 13<\currentgrouptype
2261
+ \hfil \hskip1sp \relax \fi
2262
+ \fi
2263
+ }% \tabu@flush
2264
+ \let\tabu@hfil \hfil
2265
+ \let\tabu@hfill \hfill
2266
+ \let\tabu@hskip \hskip
2267
+ \def\tabu@removehfil{%
2268
+ \iftabu@colortbl
2269
+ \unkern \tabu@cellskip =\lastskip
2270
+ \ifnum\gluestretchorder\tabu@cellskip =\tw@ \hskip-\tabu@cellskip
2271
+ \else \tabu@cellskip \z@skip
2272
+ \fi
2273
+ \else
2274
+ \ifdim\lastskip=1sp\unskip\fi
2275
+ \ifnum\gluestretchorder\lastskip =\@ne
2276
+ \hfilneg % \hfilneg for array.sty but not for colortbl...
2277
+ \fi
2278
+ \fi
2279
+ }% \tabu@removehfil
2280
+ \def\tabu@ignorehfil{\aftergroup \tabu@nohfil}
2281
+ \def\tabu@nohfil{% \hfil -> do nothing + restore original \hfil
2282
+ \def\hfil{\let\hfil \tabu@hfil}% local to (alignment template) group
2283
+ }% \tabu@nohfil
2284
+ \def\tabu@colortblalignments {% if colortbl
2285
+ \def\tabu@nohfil{%
2286
+ \def\hfil {\let\hfil \tabu@hfil}% local to (alignment template) group
2287
+ \def\hfill {\let\hfill \tabu@hfill}% (colortbl uses \hfill) pfff...
2288
+ \def\hskip ####1\relax{\let\hskip \tabu@hskip}}% local
2289
+ }% \tabu@colortblalignments
2290
+ %% Taking care of footnotes and hyperfootnotes ----------------------
2291
+ \long\def\tabu@footnotetext #1{%
2292
+ \edef\@tempa{\the\tabu@footnotes
2293
+ \noexpand\footnotetext [\the\csname c@\@mpfn\endcsname]}%
2294
+ \global\tabu@footnotes\expandafter{\@tempa {#1}}}%
2295
+ \long\def\tabu@xfootnotetext [#1]#2{%
2296
+ \global\tabu@footnotes\expandafter{\the\tabu@footnotes
2297
+ \footnotetext [{#1}]{#2}}}
2298
+ \let\tabu@xfootnote \@xfootnote
2299
+ \long\def\tabu@Hy@ftntext{\tabu@Hy@ftntxt {\the \c@footnote }}
2300
+ \long\def\tabu@Hy@xfootnote [#1]{%
2301
+ \begingroup
2302
+ \value\@mpfn #1\relax
2303
+ \protected@xdef \@thefnmark {\thempfn}%
2304
+ \endgroup
2305
+ \@footnotemark \tabu@Hy@ftntxt {#1}%
2306
+ }% \tabu@Hy@xfootnote
2307
+ \long\def\tabu@Hy@ftntxt #1#2{%
2308
+ \edef\@tempa{%
2309
+ \the\tabu@footnotes
2310
+ \begingroup
2311
+ \value\@mpfn #1\relax
2312
+ \noexpand\protected@xdef\noexpand\@thefnmark {\noexpand\thempfn}%
2313
+ \expandafter \noexpand \expandafter
2314
+ \tabu@Hy@footnotetext \expandafter{\Hy@footnote@currentHref}%
2315
+ }%
2316
+ \global\tabu@footnotes\expandafter{\@tempa {#2}%
2317
+ \endgroup}%
2318
+ }% \tabu@Hy@ftntxt
2319
+ \long\def\tabu@Hy@footnotetext #1#2{%
2320
+ \H@@footnotetext{%
2321
+ \ifHy@nesting
2322
+ \hyper@@anchor {#1}{#2}%
2323
+ \else
2324
+ \Hy@raisedlink{%
2325
+ \hyper@@anchor {#1}{\relax}%
2326
+ }%
2327
+ \def\@currentHref {#1}%
2328
+ \let\@currentlabelname \@empty
2329
+ #2%
2330
+ \fi
2331
+ }%
2332
+ }% \tabu@Hy@footnotetext
2333
+ %% No need for \arraybackslash ! ------------------------------------
2334
+ \def\tabu@latextwoe {%
2335
+ \def\tabu@temp##1##2##3{{\toks@\expandafter{##2##3}\xdef##1{\the\toks@}}}
2336
+ \tabu@temp \tabu@centering \centering \arraybackslash
2337
+ \tabu@temp \tabu@raggedleft \raggedleft \arraybackslash
2338
+ \tabu@temp \tabu@raggedright \raggedright \arraybackslash
2339
+ }% \tabu@latextwoe
2340
+ \def\tabu@raggedtwoe {%
2341
+ \def\tabu@temp ##1##2##3{{\toks@\expandafter{##2##3}\xdef##1{\the\toks@}}}
2342
+ \tabu@temp \tabu@Centering \Centering \arraybackslash
2343
+ \tabu@temp \tabu@RaggedLeft \RaggedLeft \arraybackslash
2344
+ \tabu@temp \tabu@RaggedRight \RaggedRight \arraybackslash
2345
+ \tabu@temp \tabu@justifying \justifying \arraybackslash
2346
+ }% \tabu@raggedtwoe
2347
+ \def\tabu@normalcrbackslash{\let\\\@normalcr}
2348
+ \def\tabu@trivlist{\expandafter\def\expandafter\@trivlist\expandafter{%
2349
+ \expandafter\tabu@normalcrbackslash \@trivlist}}
2350
+ %% Utilities: \fbox \fcolorbox and \tabudecimal -------------------
2351
+ \def\tabu@fbox {\leavevmode\afterassignment\tabu@beginfbox \setbox\@tempboxa\hbox}
2352
+ \def\tabu@beginfbox {\bgroup \kern\fboxsep
2353
+ \bgroup\aftergroup\tabu@endfbox}
2354
+ \def\tabu@endfbox {\kern\fboxsep\egroup\egroup
2355
+ \@frameb@x\relax}
2356
+ \def\tabu@color@b@x #1#2{\leavevmode \bgroup
2357
+ \def\tabu@docolor@b@x{#1{#2\color@block{\wd\z@}{\ht\z@}{\dp\z@}\box\z@}}%
2358
+ \afterassignment\tabu@begincolor@b@x \setbox\z@ \hbox
2359
+ }% \tabu@color@b@x
2360
+ \def\tabu@begincolor@b@x {\kern\fboxsep \bgroup
2361
+ \aftergroup\tabu@endcolor@b@x \set@color}
2362
+ \def\tabu@endcolor@b@x {\kern\fboxsep \egroup
2363
+ \dimen@\ht\z@ \advance\dimen@ \fboxsep \ht\z@ \dimen@
2364
+ \dimen@\dp\z@ \advance\dimen@ \fboxsep \dp\z@ \dimen@
2365
+ \tabu@docolor@b@x \egroup
2366
+ }% \tabu@endcolor@b@x
2367
+ %% Corrections (arydshln, delarray, colortbl) -----------------------
2368
+ \def\tabu@fix@arrayright {%% \@arrayright is missing from \endarray
2369
+ \iftabu@colortbl
2370
+ \ifdefined\adl@array % <colortbl + arydshln>
2371
+ \def\tabu@endarray{%
2372
+ \adl@endarray \egroup \adl@arrayrestore \CT@end \egroup %<original>
2373
+ \@arrayright % <FC>
2374
+ \gdef\@preamble{}}% <FC>
2375
+ \else % <colortbl / no arydshln>
2376
+ \def\tabu@endarray{%
2377
+ \crcr \egroup \egroup %<original>
2378
+ \@arrayright % <FC>
2379
+ \gdef\@preamble{}\CT@end}%
2380
+ \fi
2381
+ \else
2382
+ \ifdefined\adl@array % <arydshln / no colortbl>
2383
+ \def\tabu@endarray{%
2384
+ \adl@endarray \egroup \adl@arrayrestore \egroup %<original>
2385
+ \@arrayright % <FC>
2386
+ \gdef\@preamble{}}% <FC>
2387
+ \else % <no arydshln / no colotbl + \@arrayright missing>
2388
+ \PackageWarning{tabu}
2389
+ {\string\@arrayright\space is missing from the
2390
+ \MessageBreak definition of \string\endarray.
2391
+ \MessageBreak Comptability with delarray.sty is broken.}%
2392
+ \fi\fi
2393
+ }% \tabu@fix@arrayright
2394
+ \def\tabu@adl@xarraydashrule #1#2#3{%
2395
+ \ifnum\@lastchclass=\adl@class@start\else
2396
+ \ifnum\@lastchclass=\@ne\else
2397
+ \ifnum\@lastchclass=5 \else % <FC> @-arg (class 5) and !-arg (class 1)
2398
+ \adl@leftrulefalse \fi\fi % must be treated the same
2399
+ \fi
2400
+ \ifadl@zwvrule\else \ifadl@inactive\else
2401
+ \@addtopreamble{\vrule\@width\arrayrulewidth
2402
+ \@height\z@ \@depth\z@}\fi \fi
2403
+ \ifadl@leftrule
2404
+ \@addtopreamble{\adl@vlineL{\CT@arc@}{\adl@dashgapcolor}%
2405
+ {\number#1}#3}%
2406
+ \else \@addtopreamble{\adl@vlineR{\CT@arc@}{\adl@dashgapcolor}%
2407
+ {\number#2}#3}
2408
+ \fi
2409
+ }% \tabu@adl@xarraydashrule
2410
+ \def\tabu@adl@act@endpbox {%
2411
+ \unskip \ifhmode \nobreak \fi \@finalstrut \@arstrutbox
2412
+ \egroup \egroup
2413
+ \adl@colhtdp \box\adl@box \hfil
2414
+ }% \tabu@adl@act@endpbox
2415
+ \def\tabu@adl@fix {%
2416
+ \let\adl@xarraydashrule \tabu@adl@xarraydashrule % <fix> arydshln
2417
+ \let\adl@act@endpbox \tabu@adl@act@endpbox % <fix> arydshln
2418
+ \let\adl@act@@endpbox \tabu@adl@act@endpbox % <fix> arydshln
2419
+ \let\@preamerror \@preamerr % <fix> arydshln
2420
+ }% \tabu@adl@fix
2421
+ %% Correction for longtable' \@startbox definition ------------------
2422
+ %% => \everypar is ``missing'' : TeX should be in vertical mode
2423
+ \def\tabu@LT@startpbox #1{%
2424
+ \bgroup
2425
+ \let\@footnotetext\LT@p@ftntext
2426
+ \setlength\hsize{#1}%
2427
+ \@arrayparboxrestore
2428
+ \everypar{%
2429
+ \vrule \@height \ht\@arstrutbox \@width \z@
2430
+ \everypar{}}%
2431
+ }% \tabu@LT@startpbox
2432
+ %% \tracingtabu and the package options ------------------
2433
+ \DeclareOption{delarray}{\AtEndOfPackage{\RequirePackage{delarray}}}
2434
+ \DeclareOption{linegoal}{%
2435
+ \AtEndOfPackage{%
2436
+ \RequirePackage{linegoal}[2010/12/07]%
2437
+ \let\tabudefaulttarget \linegoal% \linegoal is \linewidth if not pdfTeX
2438
+ }}
2439
+ \DeclareOption{scantokens}{\tabuscantokenstrue}
2440
+ \DeclareOption{debugshow}{\AtEndOfPackage{\tracingtabu=\tw@}}
2441
+ \def\tracingtabu {\begingroup\@ifnextchar=%
2442
+ {\afterassignment\tabu@tracing\count@}
2443
+ {\afterassignment\tabu@tracing\count@1\relax}}
2444
+ \def\tabu@tracing{\expandafter\endgroup
2445
+ \expandafter\tabu@tr@cing \the\count@ \relax
2446
+ }% \tabu@tracing
2447
+ \def\tabu@tr@cing #1\relax {%
2448
+ \ifnum#1>\thr@@ \let\tabu@tracinglines\message
2449
+ \else \let\tabu@tracinglines\@gobble
2450
+ \fi
2451
+ \ifnum#1>\tw@ \let\tabu@DBG \tabu@@DBG
2452
+ \def\tabu@mkarstrut {\tabu@DBG@arstrut}%
2453
+ \tabustrutrule 1.5\p@
2454
+ \else \let\tabu@DBG \@gobble
2455
+ \def\tabu@mkarstrut {\tabu@arstrut}%
2456
+ \tabustrutrule \z@
2457
+ \fi
2458
+ \ifnum#1>\@ne \let\tabu@debug \message
2459
+ \else \let\tabu@debug \@gobble
2460
+ \fi
2461
+ \ifnum#1>\z@
2462
+ \let\tabu@message \message
2463
+ \let\tabu@tracing@save \tabu@message@save
2464
+ \let\tabu@starttimer \tabu@pdftimer
2465
+ \else
2466
+ \let\tabu@message \@gobble
2467
+ \let\tabu@tracing@save \@gobble
2468
+ \let\tabu@starttimer \relax
2469
+ \fi
2470
+ }% \tabu@tr@cing
2471
+ %% Setup \AtBeginDocument
2472
+ \AtBeginDocument{\tabu@AtBeginDocument}
2473
+ \def\tabu@AtBeginDocument{\let\tabu@AtBeginDocument \@undefined
2474
+ \ifdefined\arrayrulecolor \tabu@colortbltrue % <colortbl>
2475
+ \tabu@colortblalignments % different glues are used
2476
+ \else \tabu@colortblfalse \fi
2477
+ \ifdefined\CT@arc@ \else \let\CT@arc@ \relax \fi
2478
+ \ifdefined\CT@drsc@\else \let\CT@drsc@ \relax \fi
2479
+ \let\tabu@arc@L \CT@arc@ \let\tabu@drsc@L \CT@drsc@
2480
+ \ifodd 1\ifcsname siunitx_table_collect_begin:Nn\endcsname % <siunitx: ok>
2481
+ \expandafter\ifx
2482
+ \csname siunitx_table_collect_begin:Nn\endcsname\relax 0\fi\fi\relax
2483
+ \tabu@siunitxtrue
2484
+ \else \let\tabu@maybesiunitx \@firstofone % <not siunitx: setup>
2485
+ \let\tabu@siunitx \tabu@nosiunitx
2486
+ \tabu@siunitxfalse
2487
+ \fi
2488
+ \ifdefined\adl@array % <arydshln>
2489
+ \else \let\tabu@adl@fix \relax
2490
+ \let\tabu@adl@endtrial \@empty \fi
2491
+ \ifdefined\longtable % <longtable>
2492
+ \else \let\longtabu \tabu@nolongtabu \fi
2493
+ \ifdefined\cellspacetoplimit \tabu@warn@cellspace\fi
2494
+ \csname\ifcsname ifHy@hyperfootnotes\endcsname % <hyperfootnotes>
2495
+ ifHy@hyperfootnotes\else iffalse\fi\endcsname
2496
+ \let\tabu@footnotetext \tabu@Hy@ftntext
2497
+ \let\tabu@xfootnote \tabu@Hy@xfootnote \fi
2498
+ \ifdefined\FV@DefineCheckEnd% <fancyvrb>
2499
+ \tabu@fancyvrb \fi
2500
+ \ifdefined\color % <color / xcolor>
2501
+ \let\tabu@color \color
2502
+ \def\tabu@leavevmodecolor ##1{%
2503
+ \def\tabu@leavevmodecolor {\leavevmode ##1}%
2504
+ }\expandafter\tabu@leavevmodecolor\expandafter{\color}%
2505
+ \else
2506
+ \let\tabu@color \tabu@nocolor
2507
+ \let\tabu@leavevmodecolor \@firstofone \fi
2508
+ \tabu@latextwoe
2509
+ \ifdefined\@raggedtwoe@everyselectfont % <ragged2e>
2510
+ \tabu@raggedtwoe
2511
+ \else
2512
+ \let\tabu@cell@L \tabu@cell@l
2513
+ \let\tabu@cell@R \tabu@cell@r
2514
+ \let\tabu@cell@C \tabu@cell@c
2515
+ \let\tabu@cell@J \tabu@cell@j \fi
2516
+ \expandafter\in@ \expandafter\@arrayright \expandafter{\endarray}%
2517
+ \ifin@ \let\tabu@endarray \endarray
2518
+ \else \tabu@fix@arrayright \fi% <fix for colortbl & arydshln (delarray)>
2519
+ \everyrow{}%
2520
+ }% \tabu@AtBeginDocument
2521
+ \def\tabu@warn@cellspace{%
2522
+ \PackageWarning{tabu}{%
2523
+ Package cellspace has some limitations
2524
+ \MessageBreak And redefines some macros of array.sty.
2525
+ \MessageBreak Please use \string\tabulinesep\space to control
2526
+ \MessageBreak vertical spacing of lines inside tabu environnement}%
2527
+ }% \tabu@warn@cellspace
2528
+ %% tabu Package initialisation
2529
+ \tabuscantokensfalse
2530
+ \let\tabu@arc@G \relax
2531
+ \let\tabu@drsc@G \relax
2532
+ \let\tabu@evr@G \@empty
2533
+ \let\tabu@rc@G \@empty
2534
+ \def\tabu@ls@G {\tabu@linestyle@}%
2535
+ \let\tabu@@rowfontreset \@empty % <init>
2536
+ \let\tabu@@celllalign \@empty
2537
+ \let\tabu@@cellralign \@empty
2538
+ \let\tabu@@cellleft \@empty
2539
+ \let\tabu@@cellright \@empty
2540
+ \def\tabu@naturalXmin {\z@}
2541
+ \def\tabu@naturalXmax {\z@}
2542
+ \let\tabu@rowfontreset \@empty
2543
+ \def\tabulineon {4pt}\let\tabulineoff \tabulineon
2544
+ \tabu@everyrowtrue
2545
+ \ifdefined\pdfelapsedtime % <pdfTeX>
2546
+ \def\tabu@pdftimer {\xdef\tabu@starttime{\the\pdfelapsedtime}}%
2547
+ \else \let\tabu@pdftimer \relax \let\tabu@message@etime \relax
2548
+ \fi
2549
+ \tracingtabu=\z@
2550
+ \newtabulinestyle {=\maxdimen}% creates the 'factory' settings \tabu@linestyle@
2551
+ \tabulinestyle{}
2552
+ \taburowcolors{}
2553
+ \let\tabudefaulttarget \linewidth
2554
+ \ProcessOptions* % \ProcessOptions* is quicker !
2555
+ \endinput
2556
+ %%
2557
+ %% End of file `tabu.sty'.