2

I use the command include{} to import .tex files from other sources, and in one of them is used a tabularx environment. While my main/base .tex file, which is where the other .tex's are imported into, uses the command linespread{2.0} in its preamble, which functions with no doubt, only the lines in tabularx are unaffected. No matter where I add \newcommand\linespread{2.0} again, the lines in tabularx are kept in 1.0 linespread. How can I change the linespread in the tabularx into 2.0?

  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – dexteritas May 11 '18 at 13:02
  • 4
    it would be clearer if you provided an example \include isn't related to this and probably not tabularx either. Floats such as the table environment call \normalsize which will reset the line spacing. Normally you should set \baselinestretch or use a package such as setspace rather than use \linespread – David Carlisle May 11 '18 at 13:03
2

Using David Carlisle's comment you get a line spacing of 2 with

  • \usepackage[doublespacing]{setspace} for text
  • \renewcommand\baselinestretch{2}\selectfont inside table environment

Code:

\documentclass{article}

\usepackage{lipsum}
\usepackage{tabularx}
\usepackage[doublespacing]{setspace}

\begin{document}

\lipsum[1]

\begin{table}[h]
    \centering
    \renewcommand\baselinestretch{2}\selectfont
    \caption{example table}
    \begin{tabularx}{10cm}{|X|X|}
        \hline
        foo & bar\\ \hline
        foobar & foo\\ \hline
    \end{tabularx}
\end{table}

\lipsum[2]

\end{document}

Result:

enter image description here

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.