1

I want to set the space between the text of the following variables so it can look nice.

\begin{table}[H]
 \centering
    \setlength{\arrayrulewidth}{1mm}
    \renewcommand{\arraystretch}{0.65}

    \begin{threeparttable}
    \begin{tabular}{lp{12cm}{l}}

    \toprule[1.2pt]
    \textbf{Variable} & \multicolumn{1}{l}{\textbf{Description}} \\ 
    \cmidrule[0.8pt](lr){1-2}
    loan amnt & Asfasfaf Descriptive statistics for some of the                  Dictionary of the variables variables \\
    int rate & Interest rate of the loans Dictionary of the variables variables \\
    credit grade & based on its fico score Dictionary of the variables variables \\


    \midrule[1.2pt]
    \end{tabular}

     \begin{tablenotes}[online, flushleft]
   \tiny
   \item[]Notes: Dictionary for most of the variables is taken from the dictionary file
 \end{tablenotes}

    \caption{Dictionary of the variables}
    \label{tab:my_label}
    \end{threeparttable}

\end{table}

what I'm getting is

enter image description here

any suggestion?

  • Please see this question. – zyy Jun 18 '18 at 19:07
  • 1
    Why do you specify 3 columns, if you only want to use 2? And why do you use \renewcommand{\arraystretch}{0.65}? – leandriis Jun 18 '18 at 19:16
  • 1
    again you have not provided an example. the spacing you show with more space between lines in a cell than between the table rows is weird and due to code you have not shown. You should always post an example that produces the image that you post. – David Carlisle Jun 18 '18 at 19:23
  • 2
    No the code you have posted will produce no output, you should post a complete document from \documentclass to \end{document} as in the answer that is posted below. the spacing you show is due to settings you have not shown, also you use constructs not defined by default such as H and tablenotes so you make people guess how to define those to run your example at all. – David Carlisle Jun 18 '18 at 19:29
  • 2
    that said the main thing wrong is \renewcommand{\arraystretch}{0.65} which you should delete. – David Carlisle Jun 18 '18 at 19:31
2

i would redesign your table in:

enter image description here

(red lines indicate page layout)

  • please always provide complete but small document as you can see in my answer it below
  • to answer on your question is far more easy, if we know relevant part of your real document preamble (packages related to your problem and to page layout)
  • in showed solution i assume that your table can has width equal to \textwidth and for table environment use tabularx environment. its column type X automatically calculate column width.
  • for rules in table i suggest to use default thickness for rules. in the package booktabs are deliberately selected ...
  • for notes below table i would use threeparttablex with option referable, which define command \note.
  • online is not defined in threeparttable (as far as i know), instead it i use option para
  • suggest you to read some basic about table settings with latex. for start for example LaTeX/Tables

\documentclass{article}
\usepackage{booktabs, tabularx}
\usepackage[referable]{threeparttablex} % <--- for \note, \source in threepartable

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
    \begin{table}[htb]
\begin{threeparttable}
\caption{Dictionary of the variables}
    \label{tab:my_label}
\begin{tabularx}{\linewidth}{lX}
    \toprule
 \textbf{Variable} & \textbf{Description}   \\
    \midrule
oan amnt        & Asfasfaf Descriptive statistics for some of the Dictionary of the variables variables \\
int rate        & Interest rate of the loans Dictionary of the variables variables \\
credit grade    & based on its fico score Dictionary of the variables variables \\
    \bottomrule
    \end{tabularx}
    \begin{tablenotes}[para, flushleft]
    \scriptsize
\note: Dictionary for most of the variables is taken from the dictionary file
    \end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}
  • +1 Small suggestion: the code could be further simplified by removing \multicolumn{1}{l}{...} around \textbf{Description} – user36296 Jun 18 '18 at 19:33
  • ups, i forgot on this. corrected. thank you very much, @samcarter! – Zarko Jun 18 '18 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.