5

I have a longtable defined like this

\documentclass[a4paper,12pt]{report}

\usepackage{longtable} 

\begin{document}
\setlength\LTleft{0pt} 
\begin{longtable}[l]{ lllllllllllllllll }
00000576 & 576 & 577 & 578 & 579 & 580 & 581 & 582 & 583 & 584 & 585 & 586 & 587 & 588 & 589 & 590 & 591 \\ 
00000592 & 592 & 593 & 594 & 595 & 596 & 597 & 598 & 599 & 600 & 601 & 602 & 603 & 604 & 605 & 606 & 607 \\ 
00000608 & 608 & 609 & 610 & 611 & 612 & 613 & 614 & 615 & 616 & 617 & 618 & 619 & 620 & 621 & 622 & 623 \\ 
00000624 & 624 & 625 & 626 & 627 & 628 & 629 & 630 & 631 & 632 & 633 & 634 & 635 & 636 & 637 & 638 & 639 \\ 
00000640 & 640 & 641 & 642 & 643 & 644 & 645 & 646 & 647 & 648 & 649 & 650 & 651 & 652 & 653 & 654 & 655 \\ 
00000656 & 656 & 657 & 658 & 659 & 660 & 661 & 662 & 663 & 664 & 665 & 666 & 667 & 668 & 669 & 670 & 671 \\ 
00000672 & 672 & 673 & 674 & 675 & 676 & 677 & 678 & 679 & 680 & 681 & 682 & 683 & 684 & 685 & 686 & 687 \\ 
00000688 & 688 & 689 & 690 & 691 & 692 & 693 & 694 & 695 & 696 & 697 & 698 & 699 & 700 & 701 & 702 & 703 \\ 
00000704 & 704 & 705 & 706 & 707 & 708 & 709 & 710 & 711 & 712 & 713 & 714 & 715 & 716 & 717 & 718 & 719 \\ 
00000720 & 720 & 721 & 722 & 723 & 724 & 725 & 726 & 727 & 728 & 729 & 730 & 731 & 732 & 733 & 734 & 735 \\ 
00000736 & 736 & 737 & 738 & 739 & 740 & 741 & 742 & 743 & 744 & 745 & 746 & 747 & 748 & 749 & 750 & 751 \\ 
00000752 & 752 & 753 & 754 & 755 & 756 & 757 & 758 & 759 & 760 & 761 & 762 & 763 & 764 & 765 & 766 & 767 \\ 
00000768 & 768 & 769 & 770 & 771 & 772 & 773 & 774 & 775 & 776 & 777 & 778 & 779 & 780 & 781 & 782 & 783 \\ 
00000784 & 784 & 785 & 786 & 787 & 788 & 789 & 790 & 791 & 792 & 793 & 794 & 795 & 796 & 797 & 798 & 799 \\ 
00000800 & 800 & 801 & 802 & 803 & 804 & 805 & 806 & 807 & 808 & 809 & 810 & 811 & 812 & 813 & 814 & 815 \\ 
00000816 & 816 & 817 & 818 & 819 & 820 & 821 & 822 & 823 & 824 & 825 & 826 & 827 & 828 & 829 & 830 & 831 \\ 
00000832 & 832 & 833 & 834 & 835 & 836 & 837 & 838 & 839 & 840 & 841 & 842 & 843 & 844 & 845 & 846 & 847 \\ 
00000848 & 848 & 849 & 850 & 851 & 852 & 853 & 854 & 855 & 856 & 857 & 858 & 859 & 860 & 861 & 862 & 863 \\ 
00000864 & 864 & 865 & 866 & 867 & 868 & 869 & 870 & 871 & 872 & 873 & 874 & 875 & 876 & 877 & 878 & 879 \\ 
00000880 & 880 & 881 & 882 & 883 & 884 & 885 & 886 & 887 & 888 & 889 & 890 & 891 & 892 & 893 & 894 & 895 \\ 
00000896 & 896 & 897 & 898 & 899 & 900 & 901 & 902 & 903 & 904 & 905 & 906 & 907 & 908 & 909 & 910 & 911 \\ 
00000912 & 912 & 913 & 914 & 915 & 916 & 917 & 918 & 919 & 920 & 921 & 922 & 923 & 924 & 925 & 926 & 927 \\ 
00000928 & 928 & 929 & 930 & 931 & 932 & 933 & 934 & 935 & 936 & 937 & 938 & 939 & 940 & 941 & 942 & 943 \\ 
00000944 & 944 & 945 & 946 & 947 & 948 & 949 & 950 & 951 & 952 & 953 & 954 & 955 & 956 & 957 & 958 & 959 \\ 
00000960 & 960 & 961 & 962 & 963 & 964 & 965 & 966 & 967 & 968 & 969 & 970 & 971 & 972 & 973 & 974 & 975 \\ 
00000976 & 976 & 977 & 978 & 979 & 980 & 981 & 982 & 983 & 984 & 985 & 986 & 987 & 988 & 989 & 990 & 991 \\
\end{longtable}

\end{document}

This table extends very close to the end of the right side of the page. How can I set the width of such a table?

1 Answer 1

11

You can set the widths of columns using p{2cm} as for a normal tabular. With longtable you don't explicitly set the total table width but you can set the left and right margin to set the width as shown in the longtable documentation

% Normally centring is the default, but this document specifies
% \DescribeMacro{\LTright}
%\begin{verbatim}
% \setlength\LTleft\parindent
% \setlength\LTright\fill
%\end{verbatim}
% in the preamble,
%  which means that the tables are set flush left, but
% indented by the usual paragraph indentation. Any lengths can be
% specified for these two parameters, but at least one of them should be
% a rubber length so that it fills up the width of the page, unless
% rubber lengths are added between the columns using the
% "\extracolsep" command.
% For instance
%\begin{verbatim}
%  \begin{tabular*}{\textwidth}{@{\extracolsep{...}}...}
%\end{verbatim}
% produces a full width table, to get a similar effect with
% \env{longtable} specify
%\begin{verbatim}
% \setlength\LTleft{0pt}
% \setlength\LTright{0pt}
% \begin{longtable}{@{\extracolsep{...}}...}
%\end{verbatim}
%

For your table I think you either need to make the font smaller or set it landscape so either

\begin{document}
\small
\setlength\tabcolsep{2pt}
\begin{longtable}[l]{ lllllllllllllllll }

or get the lscape package and

\begin{document}
\begin{landscape}
\begin{longtable}[l]{ lllllllllllllllll }
...
\end{longtable}
\end{landscape}

Or, if you don't want your document margins to be used as margins, you can steal the space from there:

\begin{document}
\setlength\LTleft{-1in}
\setlength\LTright{-1in plus 1 fill}
\begin{longtable}{ lllllllllllllllll }
11
  • i added \begin{longtable}{ lllllllllllllllll } \setlength\LTleft{0pt} but didnt work
    – KiloWatt
    Commented Mar 2, 2012 at 16:03
  • the setlength would need to go to before the table however for that setting it is easier to use \begin{longtable}[l]{llll} and make the table go flush left. Commented Mar 2, 2012 at 16:26
  • it doesnt work for me , i think its because iam using \documentclass[a4paper , 12pt]{report}
    – KiloWatt
    Commented Mar 2, 2012 at 16:32
  • i updated my question
    – KiloWatt
    Commented Mar 2, 2012 at 16:54
  • 1
    negative spacing into the margin example added Commented Mar 2, 2012 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .