0

I have some tables with some long unbreakable formulas I want to make 100% width and not extend any further out, just wrap if need be. I have tried word-wrap: break-word combined with width: 100%; and for the most part this works fine except where the formula has hyphens in it (actually meaning minus), here it will try to break it at the hyphens only, not anywhere else during the word, even though this causes the table layout to break and extend as the hyphens are far apart.

I can fix it by using table-layout: fixed; but then it makes all the columns of each table the same width, which makes it looks ugly where I have a column with lots of a text and a column without much text in it.

Is there a property which can disable wrapping at hyphens or even a character I can use that looks like a hyphen but isn't treated as one?

Here is an example of a problem formula (excel formula):

....
    <td>
      <p class="mono first">=IF(Case_Selected="MEDIUM - BASE CASE",EOMONTH(VLOOKUP(A3,ContractData,3,FALSE),60-1),IF(Case_Selected="LOW",EOMONTH(VLOOKUP(A3,ContractDataLow,3,FALSE),60-1),IF(Case_Selected="HIGH",EOMONTH(VLOOKUP(A3,ContractDataHigh,3,FALSE),60-1),0)))</p>
    </td>
....

The mono class just makes the font monospaced and first removes the text indent (this is part of an ebook).

This cell will only break at the 60-1 parts as I think it's treating that like a hyphenated word.

jorbas
  • 311
  • 1
  • 10
  • Can you post the html of the formulas? – Yogu Feb 01 '13 at 10:06
  • possible duplicate of: http://stackoverflow.com/questions/8753296/how-to-prevent-line-break-at-hyphens-on-all-browsers – Simon Feb 01 '13 at 10:49
  • It is not clear where you would wish to allow wrapping. Using `word-wrap: break-word` would allow line breaks anywhere when needed, and it is almost always a wrong approach. – Jukka K. Korpela Feb 01 '13 at 11:21
  • In the case of these formula, I'm not at all bothered where it breaks. It just has to break where needed in order to obey `width: 100%;` which right now isn't working correctly because of the hyphens. – jorbas Feb 01 '13 at 12:13

1 Answers1

0

Zero-width spaces (&#x200b;) between each character could cause per-character breaks. However, your text might not be copy-pastable as a valid excel formula anymore, if that matters to you; and this is a little bit of a nasty hack.

The above hack shows no indication of the linebreak. If you want hyphens to appear when there's a linebreak, consider the soft-hyphen, &#xad;, instead of the zero-width space. The soft hyphen is visible only when before a line break.

Finally, if you want simply to avoid the special linebreak treatment for the minus-hyphen, you could instead use a minus-symbol: &#x2212;. Though this symbol doesn't cause breaks, it also won't prevent spaces around it (or elsewhere) from causing breaks, so you'd probably need to replace those with &nbsp; for this to do what you expect. Also, it's appearance is somewhat different from a hyphen and it too may not work on copy-paste.

I didn't test any of the symbols via copy-paste into various excel versions, so if that's relevant to you you'd need to check that yourself.

Eamon Nerbonne
  • 47,023
  • 20
  • 101
  • 166
  • Using the minus sign would be the right solution in a truly mathematical formula. But in this case, it’s an Excel formula, and this means that the symbol for substraction and sign inversion is the Ascii hyphen “-”, not the minus sign “−”. – Jukka K. Korpela Feb 01 '13 at 11:18
  • This is for a kindle book so it's unlikely anyone will be copy pasting it anywhere, I'll give it a go. – jorbas Feb 01 '13 at 12:06
  • Sorry, completely forgot about this. I talked with the customer about how he'd like it to be and they opted for just having these particular tables as images, of course this meant it couldn't be copied and pasted but they didn't see that as an issue for a kindle book. I'm not sure what to do about this question in this case. – jorbas Mar 07 '13 at 10:12