如何将一组表格合并到一个页面上?

如何将一组表格合并到一个页面上?

我正在制作层压参考卡。它由一堆表格组成,这些表格之间没有特定的顺序。

我该如何布置它们才能得到高密度参考卡?

我现在的想法是,我将渲染一些图像,然后在 Photoshop 或其他程序中手动进行最终布局,但如果有一些自动化的方法就更好了。

桌子的宽度不同,所以我不认为像这样的布局将是空间的最佳利用。

我也看过其他参考卡片设计,比如,但我怀疑他们可能不允许像我喜欢的那样密集地收集表格。

答案1

它非常适合xcoffins。它是一款旨在以非常简单的方式简化页面上内容布局的软件包:文本、表格、图像、图形等。方便构建封面和标题页以及备忘单...

它的工作原理类似于图形设计程序(几乎没有 GUI,您必须编译才能看到变化),因为它使用对象的相对位置,而不是绝对坐标。

您将材料放入带有多个手柄的特殊盒子中(在角落、侧面中间、中心等),您可以将一个盒子的手柄与另一个盒子的手柄连接起来。例如,第一个盒子的左下角与第二个盒子的左上角相连。

除此之外,您还可以添加垂直和水平偏移,以将内容精确定位在您想要的位置。

我收集了几个表格、一个列表、一个图形和一个文本(标题),并使用一个与文本区域大小相同的大框(称为)将它们(9 个对象)组合在一起,就像一个框架,\Framex用于收集其他对象。我从您提供的 Michael Goerz refcards 参考资料中获取了几个表格。

所有材料都放在框架的顶部。完成九个连接后,框架便组成一页。

在组装过程之前,我提供了一个包含盒子尺寸的表格(使用提供的工具xcoffins以及一个宏来转换ptcm)。用纸质矩形构建一个模型模型可能会有所帮助,以找到最佳排列方式。

我建议一次进行一次合并和编译,以查看框如何组合在一起以及是否需要偏移。一旦您了解使用字母 l、r、t、b、vc、hc 的句柄基本标识符的名称,该过程就会非常快。

我还建议阅读包装上的手册,复制示例以快速学习。

https://ctan.org/pkg/xcoffins?lang=en

我并未声称自己已经实现了一个很好的设计。

二十

毫米

这是代码。许多包仅用于表格。

\documentclass[10pt,a4paper,landscape]{article}

\usepackage[left=1.00cm, right=1.00cm, top=1.00cm, bottom=1.00cm]{geometry}
\usepackage{xcoffins}
\usepackage{nopageno}
\usepackage{graphicx}
\usepackage{xparse}

% Just for tables
\usepackage[table]{xcolor}
\usepackage{booktabs,multirow}
\usepackage{rotating}
\usepackage{calc}
\usepackage{tabularx}
\usepackage{upgreek}

%https://tex.stackexchange.com/questions/99550/how-do-i-convert-pt-in-cm-mm-to-em-ex-as-they-are-defined-at-a-given-point-in-th
\ExplSyntaxOn
\NewDocumentCommand{\convertto}{mm}
% #1 = em or ex (or any other unit)
% #2 = dimen to convert
{
    \texttt{#2~=~\fp_to_decimal:n { round ( (#2)/(1#1), 5 ) }#1}
}
\DeclareExpandableDocumentCommand{\thelength}{ O{mm} m }
{
    \fp_to_decimal:n { round ( #2/1#1, 1 ) } #1
}
\ExplSyntaxOff


\setlength{\parindent}{0pt}
\newlength{\Hoffset}
\newlength{\Voffset}
\setlength{\Hoffset}{10pt}
\setlength{\Voffset}{10pt}


\NewCoffin\Framex
\NewCoffin\Ri
\NewCoffin\Rii
\NewCoffin\Riii
\NewCoffin\Riv
\NewCoffin\Rv
\NewCoffin\Rvi
\NewCoffin\Rvii
\NewCoffin\Rviii
\NewCoffin\Rxiv

\begin{document}

%%  Filling *************************

\setlength{\fboxsep}{0pt}
%\SetHorizontalCoffin\Framex{\fbox{\color{gray!10}\rule{\textwidth}{\textheight-1pt}}} % Frame

\SetVerticalCoffin\Framex{\textheight}{\fbox{\color{gray!10}\rule{\textwidth}{\textheight-1pt}}} % Frame


\SetVerticalCoffin\Ri{80pt}{%   % ascii
\texttt{
    \begin{tabular*}{\textwidth}{|ccc|} 
        \cline{1-3}
        048\textit{d} & 30\textit{h} & 0 \\
        049\textit{d} & 31\textit{h} & 1 \\
        050\textit{d} & 32\textit{h} & 2 \\
        051\textit{d} & 33\textit{h} & 3 \\
        052\textit{d} & 34\textit{h} & 4 \\
        053\textit{d} & 35\textit{h} & 5 \\
        054\textit{d} & 36\textit{h} & 6 \\
        055\textit{d} & 37\textit{h} & 7 \\
        056\textit{d} & 38\textit{h} & 8 \\
        057\textit{d} & 39\textit{h} & 9 \\
        058\textit{d} & 3A\textit{h} & : \\
        059\textit{d} & 3B\textit{h} & ; \\
        060\textit{d} & 3C\textit{h} & < \\
        061\textit{d} & 3D\textit{h} & = \\
        062\textit{d} & 3E\textit{h} & > \\
        063\textit{d} & 3F\textit{h} & ? \\ 
            \cline{1-3}
    \end{tabular*}
}}

\SetVerticalCoffin\Rii{250pt}{% #fortan Computation Functions
    \small
 \begin{tabular}{l l}
    \tt ceiling(a),~floor(a)                        & to next higher/lower int \\
    \tt conjg(z)                                    & complex conjugate \\
    \tt dim(x,y)                                    & max(x-y, 0) \\
    \tt max(a1,a2,..),~min(a1,..)              & maximum/minimum \\
    \tt dprod(a,b)                                  & dp product of  sp a, b \\
    \tt mod(a,p)                                    & a mod p \\
    \tt modulo(a,p)                                 & modulo with sign of a/p \\
    \tt sign(a,b)                                   & make sign of a = sign of b \\
    \tt matmul(m1,m2)                              & matrix multiplication \\
    \tt dot\_product(a,b)                           & dot product of vectors\\  
\end{tabular}

\textbf{more:} \texttt{ sin, cos, tan, acos, asin, atan, atan2, 
    sinh, cosh, tanh, exp, log, log10, sqrt}
}

\SetVerticalCoffin\Riii{30em}{% #perl Escape Sequences:
    \begin{tabular}{p{2em}p{12em}p{2em}p{12em}}
        \textbackslash{}a & alarm (beep) & \textbackslash{}e & escape \\
        \textbackslash{}f & formfeed & \textbackslash{}n & newline \\
        \textbackslash{}r & carriage return & \textbackslash{}t & tab \\
        \multicolumn{1}{l}{\textbackslash{}cx} & control-x & \textbackslash{}l & lowercase next char \\
        \textbackslash{}L & lowercase until \textbackslash{}E & \textbackslash{}U & uppercase until \textbackslash{}E \\
        \textbackslash{}Q & diable metachars until \textbackslash{}E & \textbackslash{}E & end case modifications \\
    \end{tabular}%
}

\SetVerticalCoffin\Riv{200pt}{% Powers of Ten
    \renewcommand{\arraystretch}{1.5}
        \footnotesize   
    \begin{tabular}{|c|c|c|c|c|c|c|c|}
        \multicolumn{8}{c}{\large \textbf{Powers of Ten}}\\
        \hline
        Exa (E)   &   Peta (P)   &  Tera (T)   &     Giga (G)     &  Mega (M)  &    Kilo (k)  &   Hekto (h)  &   Deka (da)  \\
        $10^{18}$ &  $10^{15}$   &  $10^{12}$  &     $10^{9}$     &  $10^{6}$  &    $10^{3}$  &   $10^{2}$   &   $10^{1}$  \rule[-3ex]{0cm}{1ex} \\
        \hline
        Deci (d)  &   Centi (c)  &  Milli (m)  &  Micro ($\upmu$) &  Nano (n)  &    Pico (p)  &   Femto (f)  &   Atto (a)   \\
        $10^{-1}$ &  $10^{-2}$   &  $10^{-3}$  &    $10^{-6}$     & $10^{-9}$  &  $10^{-12}$  &  $10^{-15}$  &  $10^{-18}$  \rule[-3ex]{0cm}{1ex} \\
        \hline
    \end{tabular}
}

\SetVerticalCoffin\Rv{100pt}{% a figure
\includegraphics[height=100pt,width=100pt]{example-grid-100x100pt}  
}


\SetVerticalCoffin\Rvi{400pt}{% phyton  Standard Library
    \footnotesize
\begin{description}
    \item[String Services:] string, re, struct, difflib, StringIO, cStringIO, textwrap, codecs, unicodedata, stringprep, fpformat
    \item[File/Directory Access:] os.path, fileinput, stat, statvfs, filecmp, tempfile, glob, fnmatch, linecache, shutil, dircache
    \item[Generic OS services:] os, time, optparse, getopt, logging, getpass, curses, platform, errno, ctypes
    \item[Optional OS services:] select, thread, threading, dummy thread, dummy threading, mmap, readline, rlcompleter
    \item[Data Types:] datetime, calendar, collections, heapq, bisect, array, sets, sched, mutex, Queue, weakref, UserDict, UserList, UserString, types, new, copy, pprint, repr
    \item[Numeric and Math Modules:] math, cmath, decimal, random, itertools, functools, operator
    \item[Internet Data Handling:] email, mailcap, mailbox, mhlib, mimetools, mimetypes, MimeWriter, mimify, multifile, rfc822, base64, binhex, binascii, quopri, uu
    \item[Structured Markup Processing Tools:] HTMLParser, sgmllib, htmllib, htmlentitydefs, xml parsers expat, xml.dom.*, xml.sax.*, xml.etree.ElementTree
    \item[File Formats:] csv, ConfigParser, robotparser, netrc, xdrlib
    \item [Services:] hashlib, hmac, md5, sha
    \item[Compression:] zlib, gzip, bz2, zipfile, tarfile
    \item[Persistence:] pickle, cPickle, copy reg, shelve, marshal, anydbm, whichdb, dbm, gdbm, dbhash, bsddb, dumbdbm, sqlite3
    \item[Unix specific:] posix, pwd, spwd, grp, crypt, dl, termios, tty, pty, fcntl, posixfile, resource, nis, syslog, commands
    \item[IPC/Networking:] subprocess, socket, signal, popen2, asyncore, asynchat
\end{description}   
}


\SetVerticalCoffin\Rvii{0.45\textwidth}{%
\begin{tabularx}{0.45\textwidth}{@{}XX@{}}
    
    Phasellus orci quam, vehicula a, pulvinar sit amet, laoreet eget,
    massa. Cum sociis natoque penatibus et magnis dis parturient montes,
    nascetur ridiculus mus. Fusce adipiscing porttitor risus. Curabitur
    lacinia orci at ligula consequat pretium. Ut egestas. Lorem ipsum
    dolor sit amet, consectetuer elit. &
    
    Phasellus orci quam, vehicula a, pulvinar sit amet, laoreet eget,
    massa. Cum sociis natoque penatibus et magnis dis parturient montes,
    nascetur ridiculus mus. Fusce adipiscing porttitor risus. Curabitur
    lacinia orci at ligula consequat pretium. Ut egestas. Lorem ipsum
    dolor sit amet, consectetuer elit. \\
    
    Aliquam nonummy urna malesuada tellus. Nulla aliquam convallis
    quam. Aliquam auctor quam sed sapien. Vivamus auctor. Sed quam
    augue, adipiscing non, dictum id, elementum sed, turpis. Nam euismod
    faucibus nulla. Vivamus quam augue, adipiscing sed, mattis eu,
    imperdiet et, sem. Etiam malesuada elementum tellus. &
    
    Aliquam nonummy urna malesuada tellus. Nulla aliquam convallis
    quam. Aliquam auctor quam sed sapien. Vivamus auctor. Sed quam
    augue, adipiscing non, dictum id, elementum sed, turpis. Nam euismod
    faucibus nulla. Vivamus quam augue, adipiscing sed, mattis eu,
    imperdiet et, sem. Etiam malesuada elementum tellus. \\
    
        Aliquam nonummy urna malesuada tellus. Nulla aliquam convallis
    quam. Aliquam auctor quam sed sapien. Vivamus auctor. Sed quam
    augue, adipiscing non, dictum id, elementum sed, turpis. Nam euismod
    faucibus nulla. Vivamus quam augue, adipiscing sed, mattis eu,
    imperdiet et, sem. Etiam malesuada elementum tellus. &
    
    Aliquam nonummy urna malesuada tellus. Nulla aliquam convallis
    quam. Aliquam auctor quam sed sapien. Vivamus auctor. Sed quam
    augue, adipiscing non, dictum id, elementum sed, turpis. Nam euismod
    faucibus nulla. Vivamus quam augue, adipiscing sed, mattis eu,
    imperdiet et, sem. Etiam malesuada elementum tellus.
    
\end{tabularx}%
}

\SetVerticalCoffin\Rviii{100pt}{%
\begin{tabular}{clr}
    \toprule
    Alg.  & Dataset & Result \\
    \midrule
    \multirow{4}[2]{*}{\begin{sideways}BFS\end{sideways}} & soc-ork  & 1.61 \\
    & soc-lj & \cellcolor{red!10}2.95 \\
    & h09   & 1.60 \\
    & i04 & \cellcolor{blue!20}14.72 \\
    \bottomrule
\end{tabular}%
}

\SetVerticalCoffin\Rxiv{370pt}{\bfseries \Huge  Reference Card for Lamination}  % title

    %%  Assembly] *************************
\JoinCoffins\Framex[l,t]\Rii[l,t](\Hoffset,-\Voffset)           % fortran
\JoinCoffins\Framex[\Rii-r,\Rii-t]\Ri[l,t](0pt,0pt)             % ascii
\JoinCoffins\Framex[\Ri-r,\Ri-t]\Rxiv[l,t](7\Hoffset,0pt)       % title 
\JoinCoffins\Framex[\Rxiv-hc,\Rxiv-b]\Riii[hc,t](\Hoffset,-\Voffset)    % perl
\JoinCoffins\Framex[\Rii-l,\Rii-b]\Rv[l,t](0pt,-\Voffset)       % grid 100x100
\JoinCoffins\Framex[\Riii-l,\Riii-b]\Riv[l,t](-5\Hoffset,-\Voffset) % Powers of Ten
\JoinCoffins\Framex[\Rv-l,\Rv-b]\Rvi[l,t](0pt,-\Voffset)    %phyton  Standard Library
\JoinCoffins\Framex[\Rvi-r,\Rvi-t]\Rvii[l,t](\Hoffset,4\Voffset)    % tabularx
\JoinCoffins\Framex[\Rv-r,\Rv-vc]\Rviii[l,vc](2\Hoffset,0pt)    % sideways table

%%%********************************************************************

\section*{Heights and widths}
\begin{tabular}{lrr}
    \toprule    
    ID & height & width \\
    \midrule
    Ri &\thelength[mm]{\CoffinTotalHeight\Ri} & \thelength[mm]{\CoffinWidth\Ri} \\  
    Rii & \thelength[mm]{\CoffinTotalHeight\Rii} & \thelength[mm]{\CoffinWidth\Rii} \\  
    Riii & \thelength[mm]{\CoffinTotalHeight\Riii} & \thelength[mm]{\CoffinWidth\Riii} \\   
    Rvi & \thelength[mm]{\CoffinTotalHeight\Rvi} & \thelength[mm]{\CoffinWidth\Rvi} \\  
    Rv & \thelength[mm]{\CoffinTotalHeight\Rv} & \thelength[mm]{\CoffinWidth\Rv} \\ 
    Rvi & \thelength[mm]{\CoffinTotalHeight\Rvi} & \thelength[mm]{\CoffinWidth\Rvi} \\  
    Rvii & \thelength[mm]{\CoffinTotalHeight\Rvii} & \thelength[mm]{\CoffinWidth\Rvii} \\   
    Rviii & \thelength[mm]{\CoffinTotalHeight\Rviii} & \thelength[mm]{\CoffinWidth\Rviii} \\
    Rxiv & \thelength[mm]{\CoffinTotalHeight\Rxiv} & \thelength[mm]{\CoffinWidth\Rxiv} \\  % title
    \bottomrule 
\end{tabular}

\clearpage

% Typeset the assembly      
\noindent\TypesetCoffin\Framex  
    
\end{document}

最后说明。我认为最佳装箱问题并不适用于材料应遵循某种逻辑顺序的参考表。

https://en.wikipedia.org/wiki/Bin_packing_problem

尽管装箱问题具有 NP 难计算复杂度,但可以使用复杂的算法为非常大的问题实例生成最佳解决方案。此外,已经开发了许多启发式算法:例如,首次适合算法提供了一种快速但通常不是最佳的解决方案,涉及将每个物品放入它适合的第一个箱子中。它需要 Θ(n log n) 时间,其中 n 是要包装的物品数量。通过首先将物品列表按降序排列(有时称为首次适合递减算法),可以使算法更加有效,尽管这仍然不能保证最佳解决方案,并且对于较长的列表可能会增加算法的运行时间。

xcoffins包可用于实现任何启发式算法,例如下一个适合的递减高度算法,如下所示

神经性皮炎

相关内容