Skip to content

Commit

Permalink
Make full-width equations interact with floating elements better. (ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpvc committed Feb 26, 2020
1 parent d083e49 commit 3e75949
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ts/output/chtml/Wrappers/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class CHTMLmath<N, T, D> extends CommonMathMixin<CHTMLConstructor<any, an
'text-align': 'center',
margin: '1em 0'
},
'mjx-container[jax="CHTML"][display="true"][width="full"]': {
display: 'flex'
},
'mjx-container[jax="CHTML"][display="true"] mjx-math': {
padding: 0
},
Expand All @@ -83,6 +86,9 @@ export class CHTMLmath<N, T, D> extends CommonMathMixin<CHTMLConstructor<any, an
if (display) {
adaptor.setAttribute(chtml, 'display', 'true');
adaptor.setAttribute(parent, 'display', 'true');
if (adaptor.getAttribute(this.chtml, 'width') === 'full') {
adaptor.setAttribute(parent, 'width', 'full');
}
} else {
//
// Transfer right margin to container (for things like $x\hskip -2em y$)
Expand Down
10 changes: 9 additions & 1 deletion ts/output/svg/Wrappers/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {SVGWrapper, SVGConstructor} from '../Wrapper.js';
import {CommonMath, CommonMathMixin} from '../../common/Wrappers/math.js';
import {MmlMath} from '../../../core/MmlTree/MmlNodes/math.js';
import {StyleList} from '../../common/CssStyles.js';
import {BBox} from '../BBox.js';

/*****************************************************************/
/**
Expand All @@ -44,6 +45,9 @@ export class SVGmath<N, T, D> extends CommonMathMixin<SVGConstructor<any, any, a
'text-align': 'center',
margin: '1em 0'
},
'mjx-container[jax="SVG"][display="true"][width="full"]': {
display: 'flex'
},
'mjx-container[jax="SVG"][justify="left"]': {
'text-align': 'left'
},
Expand All @@ -59,14 +63,18 @@ export class SVGmath<N, T, D> extends CommonMathMixin<SVGConstructor<any, any, a
super.toSVG(parent);
const adaptor = this.adaptor;
const display = (this.node.attributes.get('display') === 'block');
const fullWidth = (this.bbox.pwidth === BBox.fullWidth);
if (display) {
adaptor.setAttribute(this.jax.container, 'display', 'true');
if (fullWidth) {
adaptor.setAttribute(this.jax.container, 'width', 'full');
}
}
const [align, shift] = this.getAlignShift();
if (align !== 'center') {
adaptor.setAttribute(this.jax.container, 'justify', align);
}
if (display && shift) {
if (display && shift && !fullWidth) {
this.jax.shift = shift;
}
if (this.jax.document.options.internalSpeechTitles) {
Expand Down

0 comments on commit 3e75949

Please sign in to comment.