3

I am building a large table and want to align the text in each "cell" to be on the top left. This does not work for the text in column 3. How do I need to change the code to make it align at the top left in column 3? enter image description here

    \begin{table}
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{|l|l|>\justify m{7cm}l|l|l|} 
\hline
Abbreviation & Name & Variable Description & Frequency & Source \\ 
\hline
\vcell{\textit{YS}} & \vcell{Yield Spread} & \vcell{Yield-to-maturity of corporate bond minus yield of maturity
  matched Treasury} & \vcell{Monthly} & \vcell{TRACE, Liu and Wu (2021)} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{SP500}} & \vcell{SP 500 return} & \vcell{Return of the SP 500 composite index} & \vcell{Monthly} & \vcell{CRSP} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{VIX}} & \vcell{VIX} & \vcell{CBOE volatility index} & \vcell{Monthly} & \vcell{McCracken
  and Ng (2016)} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{TS}} & \vcell{Term Spread} & \vcell{10-Year Treasury Rate minus 3-Month Treasury Bill} & \vcell{Monthly} & \vcell{McCracken
  and Ng (2016)} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{TR}} & \vcell{Treasury Rate} & \vcell{10-Year Treasury Rate} & \vcell{Monthly} & \vcell{McCracken
  and Ng (2016)} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{IVOL}} & \vcell{Interest rate volatility} & \vcell{Standard deviation of daily one-month constant maturity
  Treasury over a 12-month period prior to bond transaction date} & \vcell{Monthly} & \vcell{CRSP} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{DRS}} & \vcell{Default risk spread} & \vcell{Moody's Seasoned Aaa Corproate Bond Yield minus Moody's
  Seasoned Baa Corporate Bond Yield} & \vcell{Monthly} & \vcell{McCracken
  and Ng (2016)} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{MB}} & \vcell{Market-to-book ratio} & \vcell{Market value of equity divided by book value of equity} & \vcell{Quarterly} & \vcell{Compustat} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{EVOL}} & \vcell{Equity volatility} & \vcell{Standard deviation of daily excess returns over the CRSP
  value-weighted index over a 12-month period prior to bond transaction date} & \vcell{Monthly} & \vcell{CRSP} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{ER}} & \vcell{Equity return} & \vcell{REIT holding period equity return} & \vcell{Monthly} & \vcell{CRSP} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{HY}} & \vcell{High-Yield} & \vcell{1 if high-yield bond. 0 if investment-grade bond} & \vcell{Nominal} & \vcell{TRACE-Morningstar Website} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{CALL}} & \vcell{Callable~} & \vcell{1 if callable. 0 if not} & \vcell{-} & \vcell{TRACE-Morningstar Website} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{TTM}} & \vcell{Time to maturity} & \vcell{Difference in months between maturity date and transaction
  date} & \vcell{Monthly} & \vcell{TRACE-Morningstar Website} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{CR}} & \vcell{Coupon rate} & \vcell{Coupon rate on bond in percent} & \vcell{-} & \vcell{TRACE-Morningstar Website} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{LEV}} & \vcell{Leverage} & \vcell{Sum of long-term debt and short-term debt divbided by book
  value of equity} & \vcell{Quarterly} & \vcell{Compustat} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{SIZE}} & \vcell{REIT Size} & \vcell{Natural logarithm of total assets} & \vcell{Quarterly} & \vcell{Compustat} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{ROA}} & \vcell{Return on Assets} & \vcell{Net income divided by total assets} & \vcell{Quarterly} & \vcell{Compustat} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{FFO}} & \vcell{Funds from operations} & \vcell{Funds from operations} & \vcell{Quarterly} & \vcell{Compustat} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{\textit{TYPE}} & \vcell{Type of REIT} & \vcell{16 NAREIT defined types of REIT~} & \vcell{-} & \vcell{NAREIT} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\ 
\hline
\vcell{RER} & \vcell{NPI return} & \vcell{National Property Index Total Return dependent on REIT type} & \vcell{Quarterly} & \vcell{NCREIF} \\[-\rowheight]
\printcelltop & \printcelltop & \printcelltop & \printcelltop & \printcelltop \\
\hline
\end{tabular}
}
\end{table}
5
  • 1
    use p column type instead of your m : ( make m{7cm} : p{7cm} )
    – koleygr
    Commented Jul 26, 2022 at 11:53
  • 2
    thanks a lot! With p it does not seem to work but I tried it with b and it works
    – zakjak
    Commented Jul 26, 2022 at 12:00
  • 1
    Welcome to TeX.SE! We cant test your table code fragment. Please extend it to complete small document, where are in preamble loaded all needed packages and present by you defined commands. So far we cant suggest you some better way to write your table.
    – Zarko
    Commented Jul 26, 2022 at 12:22
  • How or where are \justify, \vcell, and \printcelltop defined? How is the length parameter \rowheight defined?
    – Mico
    Commented Jul 26, 2022 at 12:23
  • Welcome. // Two suggestions. 1) You don't need to show all rows, just relevant ones, like a normal and one which you don't like. This reduces code. 2) On the other hand life's easier for all of us if we can copy &compile your code and see your problem. So it's best to start with \documentclass, provide relevant packages and stop with \end{document}.
    – MS-SPO
    Commented Jul 26, 2022 at 12:26

3 Answers 3

4

Reduce as far as possible what's long and repetitive. Use variable size columns. Never scale tables.

I'm not sure what \vcell and \printcelltop are, but they can be removed, simplifying quite a lot the input.

\documentclass[a4paper]{article}
\usepackage{tabularx}

\begin{document}

\begin{table}
\centering
\footnotesize

\begin{tabularx}{\textwidth}{
  |
  l
  |
  >{\raggedright\hsize=0.5\hsize}X
  |
  >{\raggedright\hsize=1.8\hsize}X
  r
  |
  >{\raggedright\arraybackslash\hsize=0.7\hsize}X
  |
}
\hline
Abbr. & Name & Variable Description & \makebox[1em][r]{Freq.} & Source \\ 
\hline
\textit{YS} & Yield Spread
& Yield-to-maturity of corporate bond minus yield of maturity
  matched Treasury
& M & TRACE, Liu and Wu (2021) \\
\hline
\textit{SP500} & SP 500 return
& Return of the SP 500 composite index
& M & CRSP \\
\hline
\textit{VIX} & VIX
& CBOE volatility index
& M & McCracken and Ng (2016) \\
\hline
\textit{TS} & Term Spread
& 10-Year Treasury Rate minus 3-Month Treasury Bill
& M & McCracken and Ng (2016) \\
\hline
\textit{TR} & Treasury Rate
& 10-Year Treasury Rate & M
& McCracken and Ng (2016) \\
\hline
\textit{IVOL} & Interest rate volatility
& Standard deviation of daily one-month constant maturity
  Treasury over a 12-month period prior to bond transaction date
& M & CRSP \\
\hline
\textit{DRS} & Default risk spread
& Moody's Seasoned Aaa Corproate Bond Yield minus Moody's
  Seasoned Baa Corporate Bond Yield
& M & McCracken and Ng (2016) \\
\hline
\textit{MB} & Market-to-book ratio
& Market value of equity divided by book value of equity
& Q & Compustat \\
\hline
\textit{EVOL} & Equity volatility
& Standard deviation of daily excess returns over the CRSP
  value-weighted index over a 12-month period prior to bond transaction date
& M & CRSP \\
\hline
\textit{ER} & Equity return
& REIT holding period equity return
& M & CRSP \\
\hline
\textit{HY} & High-Yield &
1 if high-yield bond. 0 if investment-grade bond
& N & TRACE-MW \\
\hline
\textit{CALL} & Callable
& 1 if callable. 0 if not
& -- & TRACE-MW \\
\hline
\textit{TTM} & Time to maturity
& Difference in months between maturity date and transaction date
& M & TRACE-MW \\
\hline
\textit{CR} & Coupon rate
& Coupon rate on bond in percent
& -- & TRACE-MW \\
\hline
\textit{LEV} & Leverage
& Sum of long-term debt and short-term debt divided by book value of equity
& Q & Compustat \\
\hline
\textit{SIZE} & REIT Size
& Natural logarithm of total assets
& Q & Compustat \\
\hline
\textit{ROA} & Return on Assets
& Net income divided by total assets
& Q & Compustat \\
\hline
\textit{FFO} & Funds from operations
& Funds from operations
& Q & Compustat \\
\hline
\textit{TYPE} & Type of REIT
& 16 NAREIT defined types of REIT
& -- & NAREIT \\
\hline
\textit{RER} & NPI return
& National Property Index Total Return dependent on REIT type
& Q & NCREIF \\
\hline
\multicolumn{5}{@{}l}{M: Monthly; N: Nominal; Q: Quarterly.\qquad MW: Morningstar Website}
\end{tabularx}

\end{table}

\end{document}

enter image description here

But I'd consider a different format such as the following.

\documentclass[a4paper]{article}
\usepackage{tabularx}

\begin{document}

\begin{table}

\begin{itemize}

\item Yield Spread (YS) \\
  Yield-to-maturity of corporate bond minus yield of maturity matched Treasury.
  F:~Monthly, S:~TRACE, Liu and Wu (2021)

\item SP 500 return (SP500) \\
  Return of the SP 500 composite index.
  F:~Monthly, S:~CRSP

\item VIX \\
  CBOE volatility index.
  F:~Monthly, S:~McCracken and Ng (2016)

\item Term Spread (TS) \\
  10-Year Treasury Rate minus 3-Month Treasury Bill.
  F:~Monthly, S:~McCracken and Ng (2016)

\end{itemize}

\caption{Some caption}

\end{table}

enter image description here

Instead of a table, this might be a \section. \end{document}

3

I just guessing ... You are probably looking for something like this:

enter image description here

Sorry, but your code fragment is not of any help (regarding formatting of your table). After removing all undefined commands, using tabularray package for table, the possible solution can be:

\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tabularray}


\begin{document}    
    \begin{table}
    \small
\begin{tblr}{hlines, vlines,
            colspec = {Q[l,font=\itshape] l X[j] l l},
            row{1}  = {font=\bfseries, c}
            }

Abbr.   & Name  & Variable Description & Frequency  & Source                    \\

YS      & Yield Spread 
                & Yield-to-maturity of corporate bond minus yield of maturity
  matched Treasury 
                                        & Monthly   & TRACE, Liu and Wu (2021)   \\
SP500   & SP 500 return 
                & Return of the SP 500 composite index 
                                        & Monthly   & CRSP                      \\
VIX     & VIX   & CBOE volatility index & Monthly   & McCracken and Ng (2016)   \\
TS      & Term Spread 
                & 10-Year Treasury Rate minus 3-Month Treasury Bill 
                                        & Monthly   & McCracken and Ng (2016)   \\
TR      & Treasury Rate 
                & 10-Year Treasury Rate & Monthly   & McCracken and Ng (2016)   \\
IVOL    & Interest rate volatility 
                & Standard deviation of daily one-month constant maturity Treasury over a 12-month period prior to bond transaction date
                                        & Monthly   & CRSP                      \\
DRS     & Default risk spread 
                & Moody's Seasoned Aaa Corproate Bond Yield minus Moody's Seasoned Baa Corporate Bond Yield              
                                        & Monthly   & McCracken  and Ng (2016)  \\
MB      & Market-to-book ratio 
                & Market value of equity divided by book value of equity 
                                        & Quarterly & Compustat                 \\
EVOL    & Equity volatility 
                & Standard deviation of daily excess returns over the CRSP value-weighted index over a 12-month period prior to bond transaction date
                                        & Monthly   & CRSP                      \\
ER      & Equity return 
                & REIT holding period equity return 
                                        & Monthly   & CRSP                      \\
HY      & High-Yield 
                & 1 if high-yield bond. 0 if investment-grade bond 
                                        & Nominal   & TRACE-Morningstar Website \\
CALL    & Callable
                & 1 if callable. 0 if not 
                                        & --        & TRACE-Morningstar Website \\
TTM     & Time to maturity 
                & Difference in months between maturity date and transaction date 
                                        & Monthly   & TRACE-Morningstar Website \\
CR      & Coupon rate 
                & Coupon rate on bond in percent 
                                        & --        & TRACE-Morningstar Website \\
LEV     & Leverage 
                & Sum of long-term debt and short-term debt divbided by book value of equity 
                                        & Quarterly & Compustat                 \\
SIZE    & REIT Size
                & Natural logarithm of total assets 
                                        & Quarterly & Compustat                 \\
ROA     &   Return on Assets 
                & Net income divided by total assets 
                                        & Quarterly & Compustat                 \\
FFO     & Funds from operations 
                & Funds from operations & Quarterly & Compustat                 \\
TYPE    & Type of REIT 
                & 16 NAREIT defined types of REIT~ 
                                        & --        & NAREIT                    \\
RER     & NPI return 
                & National Property Index Total Return dependent on REIT type 
                                        & Quarterly & NCREIF                    \\
\end{tblr}
    \end{table}
\end{document}

Of course, your table can be written on other ways too. For example, with use of tabularx package. Using it, the table preamble is:

\begin{tabularx}{\linewidth}{|>{\itshape}l | X | l | l |}

where you need insert \hline after each row and on the beginning of table body. Result will look similarly (but not the same) as is shown above.

2

Here's a solution which (a) employs an xltabular environment, to allow page breaks if needed and (b) allows automatic line breaking in three of the table's 5 columns, with the width of column 3 set to three times that of column 2. That way, the adjustbox kludge can be avoided entirely, and the usable font size is \normalsize -- no need to resort to \small, \footnotesize, or any even smaller relative font size.

In the following example, the entire table happens to just fit on one page. The code is flexible enough, though, to allow an automatic page break in the tabular material if the document margins are wider than asssumed below. The mysterious \justify, \vcell, and \printcelltop macros are not needed. The code also does away with all vertical lines and most horizontal lines in order to give the table an open and inviting "look".

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters as needed
\usepackage{booktabs}   % for well-spaced horizontal rules
\usepackage{xltabular}  % for 'xltabular' environment and X col. type

%% define two subsidiary column types
\newcolumntype{L}[1]{%
   >{\raggedright\arraybackslash\hsize=#1\hsize\hspace{0pt}}X}
\newcolumntype{P}[1]{%
   >{\raggedright\arraybackslash\hspace{0pt}}p{#1}}
   
\newlength\mylen
\settowidth\mylen{and Wu (2021)} % target width of final column

\begin{document}

\begingroup % localize scope of next instruction
\setlength\extrarowheight{3pt}
\begin{xltabular}{\textwidth}{@{} >{\itshape}l L{0.5} L{1.5} c P{\mylen} @{}} 

%% headers and footers

\toprule
\textup{Abbrev.} & Name & Variable Description & Freq. & Source \\ 
\midrule
\endfirsthead

\multicolumn{5}{@{}l}{\small (\textit{continued from preceding page})}\\
\addlinespace
\toprule
\textup{Abbrev.} & Name & Variable Description & Freq. & Source \\ 
\midrule
\endhead

\midrule
\multicolumn{5}{r@{}}{\footnotesize \textit{continued on next page})}\\
\endfoot

\bottomrule
\endlastfoot

%% body of table

YS & Yield Spread & Yield-to-maturity of corporate bond minus yield of maturity matched Treasury & M & TRACE, Liu and Wu (2021) \\
SP500 & S\&P\,500 return & Return of the S\&P\,500 composite index & M & CRSP \\
VIX & VIX & CBOE volatility index & M & McCracken and Ng (2016) \\
TS & Term Spread & 10-year Treasury note rate minus 3-month Treasury bill rate & M & McCracken and Ng (2016) \\
TR & Treasury Rate & 10-year Treasury rate & M & McCracken and Ng (2016) \\
IVOL & Interest rate volatility & Standard deviation of daily one-month constant maturity Treasury over a 12-month period prior to bond transaction date & M & CRSP \\
DRS & Default risk spread & Moody's Seasoned Aaa corproate bond yield minus Moody's Seasoned Baa corporate bond yield & M & McCracken and Ng (2016) \\
MB & Market-to-book ratio & Market value of equity divided by book value of equity & Q & Compustat \\
EVOL & Equity volatility & Standard deviation of daily excess returns over the CRSP value-weighted index over a 12-month period prior to bond transaction date & M & CRSP \\
ER & Equity return & REIT holding period equity return & M & CRSP \\
HY & High-Yield & Dummy variable: 1 if high-yield bond, 0 if investment-grade bond & Nom. & TRACE-Morningstar Website \\
CALL & Callable & Dummy variable: 1 if callable, 0 if not & -- & TRACE-Morningstar Website \\
TTM & Time to maturity & Difference in months between maturity date and transaction date & M & TRACE-Morningstar Website \\
CR & Coupon rate & Coupon rate on bond in percent & -- & TRACE-Morningstar Website \\
LEV & Leverage & Sum of long-term debt and short-term debt divbided by book value of equity & Q & Compustat \\
SIZE & REIT Size & Natural logarithm of total assets & Q & Compustat \\
ROA & Return on Assets & Net income divided by total assets & Q & Compustat \\
FFO & Funds from operations & Funds from operations & Q & Compustat \\
TYPE & Type of REIT & 16 NAREIT defined types of REIT & -- & NAREIT \\
RER & NPI return & National Property Index Total Return dependent on REIT type & Q & NCREIF \\
\end{xltabular}
\endgroup

\end{document}
2
  • 1
    +1! Can you elaborate on the code that defines the two column types L and P? Commented Jul 26, 2022 at 15:09
  • 2
    @Dr.ManuelKuehner - There are up to 3 components in the definitions of the L and P column types. \raggedright\arraybackslash suspends full justification (since the columns are quite narrow); \hspace{0pt} allows hyphenation of the first word in a cell (in case the first word happens to be very long), and \hsize=#1\hsize (in the case of the L column type) allows adjusting the relative widths of the columns. The rule is that the sums of the relative widths (in the code: 0.5 and 1.5) have to add up to the number of L columns (here: 2).
    – Mico
    Commented Jul 26, 2022 at 15:19

You must log in to answer this question.

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