Re: Rechnen in LaTeX

Ulrike Fischer <[email protected]>
Newsgroups gmane.comp.tex.german
Message-ID <[email protected]>
Am Mon, 16 Dec 2024 19:36:16 +0100 schrieb Dirk Hünniger:

> Hallo,
> 
> das Ziel was ich im Moment verfolge ist eine "automatische 
> Spaltenbreite". 

> Die Frage die ich nun habe ist. Wie schreibe ich das in LaTeX hin. Also 
> wie bekomme ich LaTeX dazu diese Rechnung durchzuführen.

\documentclass{article}
\usepackage{array,lipsum}
\ExplSyntaxOn
\newcommand\mycellwidth[1]
 {
   \dim_eval:n 
     {
       \fp_eval:n
         {
           ( 
              \dim_to_decimal:n{\linewidth}
            - \dim_to_decimal:n{2\tabcolsep+\arrayrulewidth}*#1
            - \dim_to_decimal:n{\arrayrulewidth}
           )/#1
         } pt
      }
  }        
\ExplSyntaxOff
\begin{document}
\lipsum[1]

\noindent\begin{tabular}{
 |p{\mycellwidth{3}}|p{\mycellwidth{3}}|p{\mycellwidth{3}}|}
\hline bla & bla & bla\\ \hline
\end{tabular}

\end{document}

-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/

-- 
FAQ: http://texfragen.de/
Durchsuchbares Archiv: https://www.listserv.dfn.de/sympa/arc/tex-d-l 
Unsubscribe/Verwaltung: https://www.listserv.dfn.de/sympa/info/tex-d-l
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.