1

Hello I have a code below and I would like to fit it to page and center the values base on the row with of the search word. many thanks in advance.enter image description here

\documentclass[11pt,authoryear,sort&compress]{report}
\usepackage{booktabs,tabulary,array,tabularx}
\usepackage{geometry}
\newcolumntype{z}{>{\centering\arraybackslash}X}
\begin{document}
\begin{table}
    \centering
    \footnotesize
    \begin{tabularx}{1\textwidth}
        {%l
            >{\raggedright\arraybackslash}p{4cm} 
            %>{\raggedright\arraybackslash}p{3cm} 
            c
            c
            %>{\raggedright\arraybackslash}X 
            c
            c
            c
            c
            c}
        \toprule  
        Search Words & Period & Search Technique & \multicolumn{2}{c}{Initial Search Results} & Final Sample &
        \multicolumn{2}{c}{Analysis Perform}\tabularnewline
        \cline{4-5} \cline{5-5} 
        &  &  & No. of articles & Total local citations &  &  & \tabularnewline
        (("determinants" or "discrimination") and ("finance" or "credit" or  "capital" or "financial services") and ("access")) & 5 & 5 & 5 & 5 & 5 & 5 & 5\tabularnewline
        & &\tabularnewline
        ("financial inclusion") & 5 & 5 & 5 & 5 & 5 & 5 & 5\tabularnewline
        \bottomrule%
    \end{tabularx}%
    \caption{caption.}
    \label{tab:final.sample.biblio} 
\end{table}

\end{document}
1
  • 1
    A tabularx environment without any X type column doesn't make sense. To start, you could try to replace the p type column you currently use for the first column with an X type column. To save some space, allow line breaks in the column headers.
    – leandriis
    May 8 at 9:40
1

As mentioned in my previous comment, a tabularx environment without any X type column doesn't make sense. The first step is replacin the p type column you currently use for the first column with an X type column. Since this column now gets too narrow, we could allow line breaks inside of the column headers. To do so, I used the \thead command from the makecell package. In order to avoid large spaces inside of the first column, I added >{\raggedright\arraybackslash} to switch from justified to ragged right alignment. I also replaced the \cline commands with \cmidrule from the booktabs package, that you already used. I also slightly reduced the value of \tabcolsep and increased the font size from \footnotesize to \small. In order to vertically center the contents of each cell with respect to the contents in the first column, I added \renewcommand\tabularxcolumn[1]{m{#1}}. Lastly, I couldn't understand the reason for \cline{4-5} \cline{5-5} and guessed that there were some column headers missing in the last two columns, so I added them.

enter image description here

\documentclass[11pt]{report}
\usepackage{booktabs,tabularx}
\usepackage{geometry}
\usepackage{makecell}
    
\begin{document}
\begin{table}
    \small
    \renewcommand\tabularxcolumn[1]{m{#1}}
    \renewcommand{\theadalign}{tc}
    \setlength{\tabcolsep}{4pt}
    \caption{caption.}
    \label{tab:final.sample.biblio} 
    \begin{tabularx}{1\textwidth}
        {@{}
            >{\raggedright\arraybackslash}X
            c
            c 
            c
            c
            c
            c
            c @{}}
        \toprule  
        \thead[l]{Search Words} & \thead{Period} & \smash{\thead{Search\\ Technique}} & \multicolumn{2}{c}{\thead{Initial Search Results}} &  \smash{\thead[t]{Final\\ Sample}} &
        \multicolumn{2}{c}{Analysis Perform}\tabularnewline
        \cmidrule(lr){4-5} \cmidrule(lr){7-8}
        &  &  & \thead{No. of\\ articles} & \thead{Total local\\ citations} &  &  \thead{text} & \thead{text} \tabularnewline
        \midrule
        (("determinants" or "discrimination") and ("finance" or "credit" or  "capital" or "financial services") and ("access")) & 5 & 5 & 5 & 5 & 5 & 5 & 5\tabularnewline
        & &\tabularnewline
        ("financial inclusion") & 5 & 5 & 5 & 5 & 5 & 5 & 5\tabularnewline
        \bottomrule%
    \end{tabularx}%
\end{table}

\end{document}
2
  • thank you very much <3 May 8 at 9:59
  • 1
    @SeymaKalay: You're welcome. I just added some explanations on what I changed an why I changed it, in case you're interested.
    – leandriis
    May 8 at 10:00

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.