2

I can't find it in the manual or elsewhere.

How can I make a linebreak like \\ or \newline in spreadtab tables text (@longtext sentences) cells?

Edit providing a MWE:

\documentclass[a4paper]{article}
\usepackage{spreadtab}
\begin{document}
    \begin{figure}
    \subsection{Zeitaufwand}
     \begin{footnotesize} 
    \begin{center}
      \begin{spreadtab}{{tabular}{ | l | c | c | c | l | }} \hline
       @ Arbeitspaket   & @ geplant     & @ geleistet   & @ delta   & @ Erklärung \\ \hline     
       @ xy             & 1             & 1             &           & \\ 
       @ zab            & 2             & 8             &  6        & \\     %below i wold like to get a linebreak....
       @ cde            & 8             & 11            &  5        & @ \begin{scriptsize}Some long sentence with no line break.\end{scriptsize}\\      
       \hline \hline         
       @ Total          & sum(b2:b4)    & sum(c2:c4)    & sum(d2:d4) & @ h \\ \hline
        \end{spreadtab}
      \caption{Zeitaufwand}
      \label{tab:Zeitaufwand} 
    \end{center}  
   \end{footnotesize} 
  \end{figure}
\end{document}
  • 1
    As you might know from your previous questions, it is easier to help you if you provide the code of a complete document that illustrates your problem. Thanks. – gernot says Reinstate Monica Mar 5 '17 at 14:53
  • There is no reference of @longtext anywhere in spreadtab's manual – at least not in the current version (v0.4c). Please give us a minimal working example! – clemens Mar 5 '17 at 15:47
  • I'm guessing you're refering to the fact that cells with an @ in them make them text cells in spreadtab's eyes (cf. section 2.3 of the manual)? – clemens Mar 5 '17 at 15:49
  • exactly at the point of @ text i can't create a linebreak... hope its posible somehow... – novski Mar 6 '17 at 17:12
2

Package makecell is your friend here. To get more informations type texdoc makecell on your terminal/console.

Because \subsection should not be used in figure I moved it outside figure. To get the \subsection before figure I added the option [!hb] to the environment figure. There is no environment footnotesize, I changed it to the existing command \footnotesize. Environment center adds a space, to omit that I used command \centering.

Please see the following MWE (important changes are marked with <========):

\documentclass[a4paper]{article}

\usepackage{spreadtab}
\usepackage{makecell} % <===============================================

\begin{document}

\subsection{Zeitaufwand}
\begin{figure}[!hb] % <===================================
  \footnotesize % <=====================================================
  \centering % <========================================================
  \begin{spreadtab}{{tabular}{ | l | c | c | c | l | }} \hline
    @ Arbeitspaket   & @ geplant     & @ geleistet   & @ delta   & @ Erklärung \\ \hline     
    @ xy             & 1             & 1             &           & \\ 
    @ zab            & 2             & 8             &  6        & @\makecell{\emph{Some} long sentence with a line break.\\Some long sentence with no line \emph{break}.} \\% <================
    @ cde            & 8             & 11            &  5        & @ \scriptsize Some long sentence with no line break.\\
    \hline \hline         
    @ Total          & sum(b2:b4)    & sum(c2:c4)    & sum(d2:d4) & @ h \\ \hline
  \end{spreadtab}
  \caption{Zeitaufwand}
  \label{tab:Zeitaufwand} 
\end{figure}

\end{document}

which results in the following pdf:

resulting pdf

Command \makecell{Text\\Text2} adds two lines Text and in the next line Text2 into the cell without breaking the automatic of calculations in spreadtab.

  • +1 but \subsection should not be used in figure and footnotesize etc. are not environments. – Andrew Swann Oct 22 '17 at 12:22

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.