两页长的表格

两页长的表格

我有以下表格,我想将其扩展到 2+ 页。我尝试过使用、、longtable等,但一定是哪里做错了。它原本是一个表格,我想尽可能保留原始格式(因为其他贡献者应该会添加到表格中)。我怎样才能让它扩展到多个页面,同时对表格的内容进行最少的修改(即保留、等)?谢谢。ltxtabletabutabularxhdashlinemulticolumn

PS-(我希望标题位于图表/页面的底部,因为文档的其余部分也是如此。)

例子

% Example
\documentclass[a4paper, 11pt]{article}

\usepackage{amsmath} % Nice maths symbols.
\usepackage{amssymb} % Nice variable symbols.
\usepackage{array} % Allow for custom column widths in tables.
\usepackage{arydshln} % Dashed lines using \hdashline \cdashline
\usepackage{bbm} % Gives Blackboard fonts.
\usepackage{bm} % Bold math symbols.
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash]{caption} % Caption figures and tables nicely.
\usepackage{enumitem} % Nice listing options in itemize and enumerate.
\usepackage{esdiff} % Gives nice differential operators.
\usepackage{esvect} % Gives nice vector arrows.
\usepackage{float} % Nice figure placement.
\usepackage{geometry} % Use nice margins.
\usepackage{graphicx} % Include figures.
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue,anchorcolor=blue]{hyperref} % Colour links.
\usepackage{indentfirst} % Indents the first paragraph.
\usepackage{letltxmacro} % For defining a nice SQRT symbol.
\usepackage{multirow} % Nice table cells spanning many rows.
\usepackage{multicol} % If I want to use multiple columns.
\usepackage[numbers, sort&compress]{natbib} % Nice references.
\usepackage{physics} % Nice partial derivatives and BRAKET notation.
\usepackage{subcaption} % Side by side figures.
\usepackage{tabularx} % Tables with justified columns.
\usepackage{tikz} % For drawing pictures.

% Gives nice margins.
\geometry{left=20mm, right=20mm, top=20mm, bottom=20mm}

% Removes hyphenation
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000

% Custom column widths using C{2cm}, L, R, etc.
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\begin{document}


\begin{table}[hbt]
\begin{center}
\footnotesize
% Try to input a short description (no more than 1 or 2 lines) of algorithms in alphabetical order.
\begin{tabularx}{\textwidth}{|L{0.4\textwidth}|X|}
\hline 
\multicolumn{1}{|c|}{Algorithm}  % use \texttt{text} instead of \verb|text| to allow line breaks for long function names.
& \multicolumn{1}{c|}{Description} \\
\hline 
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hline
\end{tabularx}
\caption{Available algorithms for solving the travelling salesman problem, giving the function name and a brief description.}
\label{tab:brief_algorithm_descriptions}
\end{center}
\end{table}    

\end{document}

答案1

这里有一个使用包的方法,它将的ltablex功能带到。注意,必须加载longtabletabularx arydshln。我\multicolumn{1}{c|}用一个简单的替换了centering

\documentclass[a4paper, 11pt]{article}

\usepackage{amsmath} % Nice maths symbols.
\usepackage{amssymb} % Nice variable symbols.

\usepackage{ltablex} % Tables with justified columns. long tabularx
\usepackage{array} % Allow for custom column widths in tables.
\usepackage{arydshln} % Dashed lines using \hdashline \cdashline
\usepackage{bbm} % Gives Blackboard fonts.
\usepackage{bm} % Bold math symbols.
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash]{caption} % Caption figures and tables nicely.
\usepackage{enumitem} % Nice listing options in itemize and enumerate.
\usepackage{esdiff} % Gives nice differential operators.
\usepackage{esvect} % Gives nice vector arrows.
\usepackage{float} % Nice figure placement.
\usepackage{geometry} % Use nice margins.
\usepackage{graphicx} % Include figures.
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue,anchorcolor=blue]{hyperref} % Colour links.
\usepackage{indentfirst} % Indents the first paragraph.
\usepackage{letltxmacro} % For defining a nice SQRT symbol.
\usepackage{multirow} % Nice table cells spanning many rows.
\usepackage{multicol} % If I want to use multiple columns.
\usepackage[numbers, sort&compress]{natbib} % Nice references.
\usepackage{physics} % Nice partial derivatives and BRAKET notation.
\usepackage{subcaption} % Side by side figures.
\usepackage{tikz} % For drawing pictures.

% Gives nice margins., showframe
\geometry{margin=20mm}

% Removes hyphenation
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000

% Custom column widths using C{2cm}, L, R, etc.
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

{\footnotesize\setlength\extrarowheight{1.5pt}\keepXColumns
% Try to input a short description (no more than 1 or 2 lines) of algorithms in alphabetical order.
\begin{tabularx}{\textwidth}{|L{0.4\textwidth}| >{\arraybackslash}X|}
\caption{Available algorithms for solving the travelling salesman problem, giving the function name and a brief description.}
\label{tab:brief_algorithm_descriptions}\\
\hline
\centering Algorithm % use \texttt{text} instead of \verb|text| to allow line breaks for long function names.
& \centering Description \tabularnewline
\hline
\endfirsthead
\hline
 \centering Algorithm % use \texttt{text} instead of \verb|text| to allow line breaks for long function names.
& \centering Description \tabularnewline
\hline
\endhead
\multicolumn{2}{r}{\em To be continued}
 \endfoot
\hline
 \endlastfoot
 \texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} & Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} & Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} & Miller-Tucker-Zemlin algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} & A greedy nearest neighbours algorithm added the shortest possible edge. \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} & A greedy nearest neighbours algorithm using a specific starting point. \\
\hdashline
\texttt{RG\_stochastic.m} & Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} & Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} & Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} & Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} & Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} & A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} & Performs a 2-opt local search. \\
\hdashline
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} & Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} & Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} & Miller-Tucker-Zemlin algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} & A greedy nearest neighbours algorithm added the shortest possible edge. \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} & A greedy nearest neighbours algorithm using a specific starting point. \\
\hdashline
\texttt{RG\_stochastic.m} & Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} & Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} & Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} & Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} & Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} & A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} & Performs a 2-opt local search.
\end{tabularx}}

\end{document} 

在此处输入图片描述

在此处输入图片描述

答案2

一些评论:

  • 您不能在环境longtable中嵌套table

  • 如果您要使用,请不要忽视为、、和标记提供材料的longtable需要。\endfirsthead\endhead\endfoot\endlastfoot

  • 对于多页表格,通常在表格顶部而不是表格底部提供表格标题。

  • 我认为在第一列中允许材料换行是不对的。因此,我建议您l对第一列使用普通列类型。

  • \hdashline我会删除所有说明,用更多空白来代替,让表格材料看起来更加开放。中心垂直线似乎没有必要。

  • \textt{...}由于第一列中的所有条目(标题材料除外)都应使用等宽字体排版,因此您可以通过将列规范从 更改为 来节省大量“包装器”l的输入>{\ttfamily}l

在此处输入图片描述

\documentclass[a4paper, 11pt]{article}
% I've condensed the preamble to the bare mininum.
\usepackage{array} 
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash]{caption} 
\usepackage{longtable}
\usepackage[margin=20mm]{geometry} 
\newcolumntype{L}[2]{>{\raggedright\arraybackslash}p{#1}}

\begin{document}
\begingroup
\setlength\extrarowheight{3pt} % for a more open look
\small
\begin{longtable}{|>{\ttfamily}l L{0.62\textwidth}|}

%% header and footer material

\caption{Available algorithms for solving the travelling salesman problem, giving the function name and a brief description.}
\label{tab:brief_algorithm_descriptions}\\
\hline 
\multicolumn{1}{|l}{Algorithm} & Description \\
\hline 
\endfirsthead

\multicolumn{2}{l}{Table \ref{tab:brief_algorithm_descriptions}, continued}\\[2ex]
\hline 
\multicolumn{1}{|l}{Algorithm} & Description \\
\hline 
\endhead

\hline
\multicolumn{2}{r}{\em Continued on following page}\\
\endfoot

\hline
\endlastfoot

%% body of longtable

edgeupperbound.m & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\

FD\_bruteForce.m & Explores all possible paths recursively tracking the total distance of smaller networks. \\

FD\_dynamicProgramming.m & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\

FD\_greedy.m & Greedy algorithm increases the path size by including the nearest city. \\

FD\_LPTSP.m &  Integer linear programming solver. \\

FD\_LPTSPit.m &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\

FD\_stochastic.m & Random permutations of paths are considered for a given number of trials. \\

forcefully\_increasing\_loop.m & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\

greedy\_algorith\_TSP.m & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\

greedy\_algorith\_TSP\_all.m & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\

increasing\_loop.m & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\

IntLinProgCutSetTSP.m & Integer programming method without the cut-set constraint. \\

linprogtsp2.m &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\

nearestneigh.m &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\

optimal\_greedy\_TSP.m &  A greedy nearest neighbours algorithm using a specific starting point.  \\

RG\_stochastic.m &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\

search\_permutations.m &  Exhaustive search over all path permutations. \\

stochastic\_TSP.m &  Randomly generates paths, using the shortest over a fixed number of iterations. \\

tabu\_search.m &  Performs a Tabu search. \\

tsp\_ip\_no\_cut\_set\_oliver.m & Integer programming solver which allows sub-loops.\\

tsp\_lp\_no\_cut\_set\_oliver.m & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
two\_opt\_search.m &  Performs a 2-opt local search. \\

TwoHeadedSnake.m &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\

twoopt.m &  Performs a 2-opt local search. \\

edgeupperbound.m & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\

FD\_bruteForce.m & Explores all possible paths recursively tracking the total distance of smaller networks. \\

FD\_dynamicProgramming.m & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\

FD\_greedy.m & Greedy algorithm increases the path size by including the nearest city. \\

FD\_LPTSP.m &  Integer linear programming solver. \\

FD\_LPTSPit.m &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\

FD\_stochastic.m & Random permutations of paths are considered for a given number of trials. \\

forcefully\_increasing\_loop.m & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\

greedy\_algorith\_TSP.m & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\

greedy\_algorith\_TSP\_all.m & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\

increasing\_loop.m & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\

IntLinProgCutSetTSP.m & Integer programming method without the cut-set constraint. \\

linprogtsp2.m &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\

nearestneigh.m &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\

optimal\_greedy\_TSP.m &  A greedy nearest neighbours algorithm using a specific starting point.  \\

RG\_stochastic.m &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\

search\_permutations.m &  Exhaustive search over all path permutations. \\

stochastic\_TSP.m &  Randomly generates paths, using the shortest over a fixed number of iterations. \\

tabu\_search.m &  Performs a Tabu search. \\

tsp\_ip\_no\_cut\_set\_oliver.m & Integer programming solver which allows sub-loops.\\

tsp\_lp\_no\_cut\_set\_oliver.m & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
two\_opt\_search.m &  Performs a 2-opt local search. \\

TwoHeadedSnake.m &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\

twoopt.m &  Performs a 2-opt local search. \\

\end{longtable}
\endgroup
\end{document}

答案3

使用longtabu与列规范{|X[4,l]|X[6,j]|}(第一列左对齐,40%,第二列两端对齐,60%)。

不要使用,arydshln因为它与禁忌相冲突,而是\hdasline根据 来定义\tabucline。它可以使用虚线周围的更多间距;不幸的是,tabu对于多行单元格来说,它不能很好地做到这一点。

在每一页上设置重复页眉。

这是您改编的示例。只需进行少量编辑。

\documentclass[a4paper, 11pt]{article}

\usepackage{amsmath} % Nice maths symbols.
\usepackage{amssymb} % Nice variable symbols.
\usepackage{array} % Allow for custom column widths in tables.
\usepackage{bbm} % Gives Blackboard fonts.
\usepackage{bm} % Bold math symbols.
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash]{caption} % Caption figures and tables nicely.
\usepackage{enumitem} % Nice listing options in itemize and enumerate.
\usepackage{esdiff} % Gives nice differential operators.
\usepackage{esvect} % Gives nice vector arrows.
\usepackage{float} % Nice figure placement.
\usepackage{geometry} % Use nice margins.
\usepackage{graphicx} % Include figures.
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,citecolor=blue,anchorcolor=blue]{hyperref} % Colour links.
\usepackage{indentfirst} % Indents the first paragraph.
\usepackage{letltxmacro} % For defining a nice SQRT symbol.
\usepackage{multirow} % Nice table cells spanning many rows.
\usepackage{multicol} % If I want to use multiple columns.
\usepackage[numbers, sort&compress]{natbib} % Nice references.
\usepackage{physics} % Nice partial derivatives and BRAKET notation.
\usepackage{subcaption} % Side by side figures.
%\usepackage{tabularx} % Don't use tabularx
\usepackage{longtable,tabu} % Use longtabu instead
\usepackage{tikz} % For drawing pictures.
%\usepackage{arydshln} % Don't use arydshln (clashes with tabu).
\newcommand\hdashline{\tabucline[\arrayrulewidth on 4pt off 4pt]}

% Gives nice margins.
\geometry{left=20mm, right=20mm, top=20mm, bottom=20mm}

% Removes hyphenation
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000

% Custom column widths using C{2cm}, L, R, etc.
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

\footnotesize
% Try to input a short description (no more than 1 or 2 lines) of algorithms in alphabetical order.
\begin{longtabu} to \textwidth {|X[4,l]|X[6,j]|}
\hline 
\multicolumn{1}{|c|}{Algorithm}  % use \texttt{text} instead of \verb|text| to allow line breaks for long function names.
& \multicolumn{1}{c|}{Description} \\
\hline \endhead
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hline 
\caption{Available algorithms for solving the travelling salesman problem, giving the function name and a brief description.}
\label{tab:brief_algorithm_descriptions}
\end{longtabu}

\end{document}

答案4

您正在代码中的另一个表中创建一个表。

如果我理解正确的话,这段代码就是执行您想要的操作:

\documentclass[a4paper, 11pt]{article}

% I removed some packages from the list which are not needed for this table
\usepackage{longtable,ltablex}
\usepackage{array}
\usepackage{arydshln}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=endash]{caption} % Caption figures and tables nicely.
\usepackage{geometry}
\usepackage{multirow}
\usepackage{multicol}

% Gives nice margins.
\geometry{left=20mm, right=20mm, top=20mm, bottom=20mm}

% Custom column widths using C{2cm}, L, R, etc.
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}

\begin{document}

\begin{center}
%\footnotesize
\renewcommand{\arraystretch}{1.1} % some stretching (better layout)
\begin{tabularx}{\textwidth}{|L{0.4\textwidth}|X|}
\hline 
\multicolumn{1}{|c|}{Algorithm} & \multicolumn{1}{c|}{Description} \\
\hline 
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{edgeupperbound.m} & Adds the cheapest unused edge that won't create a fork or a loop until a path is formed, then adds in the final edge to create a loop. \\
\hdashline
\texttt{FD\_bruteForce.m} & Explores all possible paths recursively tracking the total distance of smaller networks. \\
\hdashline
\texttt{FD\_dynamicProgramming.m} & Explores all possible paths ending in a given city, iteratively increasing the network size using the Held-Karp algorithm. \\
\hdashline
\texttt{FD\_greedy.m} & Greedy algorithm increases the path size by including the nearest city. \\
\hdashline
\texttt{FD\_LPTSP.m} &  Integer linear programming solver. \\
\hdashline
\texttt{FD\_LPTSPit.m} &  Integer linear programming solver which ignores the cut-set constraint, but does constrain against sub-cycles. \\
\hdashline
\texttt{FD\_stochastic.m} & Random permutations of paths are considered for a given number of trials. \\
\hdashline
\texttt{forcefully\_increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by forcefully including a random city by changing the route by the amount. \\
\hdashline
\texttt{greedy\_algorith\_TSP.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops. \\
\hdashline
\texttt{greedy\_algorith\_TSP\_all.m} & Greedy algorithm moves to shortest edge, not allowing for sub-loops, and uses a specific starting point. \\
\hdashline
\texttt{increasing\_loop.m} & Begins with a small loop, progressively increasing the size of the route by including the city which increases the distance by the minimal amount. \\
\hdashline
\texttt{IntLinProgCutSetTSP.m} & Integer programming method without the cut-set constraint. \\
\hdashline
\texttt{linprogtsp2.m} &  Miller-Tucker-Zemlin  algorithm, uses cut-set constraints. \\
\hdashline
\texttt{nearestneigh.m} &  A greedy nearest neighbours algorithm added the shortest possible edge.  \\
\hdashline
\texttt{optimal\_greedy\_TSP.m} &  A greedy nearest neighbours algorithm using a specific starting point.  \\
\hdashline
\texttt{RG\_stochastic.m} &  Generates random paths iteratively saving the best result for a chosen number of iterations. \\
\hdashline
\texttt{search\_permutations.m} &  Exhaustive search over all path permutations. \\
\hdashline
\texttt{stochastic\_TSP.m} &  Randomly generates paths, using the shortest over a fixed number of iterations. \\
\hdashline
\texttt{tabu\_search.m} &  Performs a Tabu search. \\
\hdashline
\texttt{tsp\_ip\_no\_cut\_set\_oliver.m} & Integer programming solver which allows sub-loops.\\
\hdashline
\texttt{tsp\_lp\_no\_cut\_set\_oliver.m} & Linear programming solver which allows sub loops and partial journeys (non-physical).\\
\texttt{two\_opt\_search.m} &  Performs a 2-opt local search. \\
\hdashline
\texttt{TwoHeadedSnake.m} &  A two headed greedy algorithm for finding a Hamiltonian cycle by adding the nearest two cities iteratively. \\
\hdashline
\texttt{twoopt.m} &  Performs a 2-opt local search. \\
\hline
\caption{Available algorithms for solving the travelling salesman problem, giving the function name and a brief description.}
\label{tab:brief_algorithm_descriptions}
\end{tabularx}
\renewcommand{\arraystretch}{1} % reset stretching
\end{center}

\end{document}

相关内容