[Tex/LaTex] Changing the rules of line breaks

line-breakingpgfplotstable

I used pgfplotstable to read the data from a file.

The columns have fixed widths. The third column contains usual text and the lines are broken nicely. The second column contains mathematical expressions, which don't have white spaces and can be quite long and surpass the width of the column. In that case I want the expression to break and resume on the next line.

At the moment, line breaks can only occur next to some special characters (like the minus sign, see the third row), but I want it to be able to occur next to some other characters (for example, the asterisk). So, for example, the first line could break after "-V_lm/(epsilon0_const*2*pir)" and the next line could have "1[F]*1[V/m]".

Does anybody know how to accomplish this?

Also the code (which is not really relevant to the problem, but just in case) :

\begin{table}[H]
\centering
\newcolumntype{C}{>{}p{60mm}}% a centered fixed-width-column
\pgfplotstabletypeset[
    col sep=ampersand,
    columns/Name/.style={verb string type},
    columns/Expression/.style={column type=|C, verb string type},
    columns/Description/.style={column type=|C, verb string type},
    empty cells with={--}, % replace empty cells with ’--’
    every head row/.style={before row=\toprule,after row=\midrule},
    every last row/.style={after row=\bottomrule},
]{./equations.txt}
\caption{Implementation.}
\end{table}

The file I'm reading the data from:

Name&Expression&Description
normE&-V_lm/(epsilon0_const*2*pi*r)*1[F]*1[V/m]&Normal electric field (V/m)
T&T[1/K]&Temperature (K)
F&max(g_normE*1[m/V]*1e-9,1e-12)&product of local electric field strength and elementary charge (eV/nm)

Best Answer

enter image description here

Mico's just posted a url version, but if you want to control individual characters by hand:

\documentclass{article}
\usepackage{array}
\usepackage[T1]{fontenc}
\begin{document}

\newcolumntype{C}{>{\centering\arraybackslash}p{60mm}}% a centered fixed-width-column
{\catcode`_=12
\begin{tabular}{lCC}
Name&Expression&Description\\
normE&-V_lm/(epsilon0_const*2*pi*r)*1[F]*1[V/m]&Normal electric field (V/m)\\
T&T[1/K]&Temperature (K)\\
F&max(g_normE*1[m/V]*1e-9,1e-12)&product of local electric field strength and elementary charge (eV/nm)
\end{tabular}
}

\bigskip

{\catcode`_=12
\catcode`*\active
\def*{\string*\linebreak[0]}
\begin{tabular}{lCC}
Name&Expression&Description\\
normE&-V_lm/(epsilon0_const*2*pi*r)*1[F]*1[V/m]&Normal electric field (V/m)\\
T&T[1/K]&Temperature (K)\\
F&max(g_normE*1[m/V]*1e-9,1e-12)&product of local electric field strength and elementary charge (eV/nm)
\end{tabular}
}

\end{document}