Code Monkey home page Code Monkey logo

Comments (12)

murkle avatar murkle commented on August 12, 2024

Doesn't sound like a jlatexmath bug as there's no automatic line-breaking support

In any case, you'll need to provide the exact LaTeX strings ("English" and "Asian") that you are sending to the library if you want us to check further

from jlatexmath.

fnatter avatar fnatter commented on August 12, 2024

Doesn't sound like a jlatexmath bug as there's no automatic line-breaking support

hello murkle,

I am the (co)author of the Freeplane LaTeX plugin, and I am quite sure that JLaTeXMath supports automatic line breaking
using the TeXIconBuilder interface (inner class in TeXFormula.java, I introduced this a long time ago):

		return tf.new TeXIconBuilder()
			.setStyle(style)
			.setSize(size)
			.setWidth(TeXConstants.UNIT_PIXEL, maxWidth, align)
			.setIsMaxWidth(true)
//			.setInterLineSpacing(TeXConstants.UNIT_PIXEL, /*40f*/size * 1.2F)
			.setInterLineSpacing(latexInterlineSpacingUnit, latexInterlineSpacingValue)
			.build();

https://github.com/freeplane/freeplane/blob/1.9.x/freeplane_plugin_latex/src/main/java/org/freeplane/plugin/latex/TeXText.java#L72

Cheers and Best Regards,
Felix

from jlatexmath.

BeniaminK avatar BeniaminK commented on August 12, 2024
package com.bendzi.frameworks.jlatexmath;

import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;

import javax.swing.*;
import java.awt.*;

public class JLatexMathTesting {

    public static void main(String[] argv) {

        String chineseText = "是次合作為大型科研計劃「大灣區光化學臭氧污染及區域和跨區域傳輸特徵研究」的一部分。該計劃由廣東省政府、香港特區政府和澳門特區政府聯合推出,旨在研究臭氧對整個區域所造成的空氣質素問題。";
        String englishText = "I live in a house near the mountains. I have two brothers and one sister, and I was born last. ";
        
        String englishLongWord = englishText.replaceAll(" ", "");
        
        String koreanText = " 모든 사람은 교육을 받을 권리를 가진다 . 교육은 최소한 초등 및 기초단계에서는 무상이어야 한다. 초등교육은 의무적이어야 한다. 기술 및 직업교육은 일반적으로 접근이 가능하여야 하며, 고등교육은 모든 사람에게 실력에 근거하여 동등하게 접근 가능하여야 한다.";
        
        String koreanLongWord = koreanText.replaceAll(" ", "");

        String[] texts = {
                chineseText,
                englishText,
                englishLongWord,
                koreanText,
                koreanLongWord,

        };

        JFrame jf = new JFrame();

        GridLayout layoutManager = new GridLayout(texts.length, 1);

        JPanel contentPane = new JPanel(layoutManager);
        contentPane.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

        jf.setContentPane(contentPane);

        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        for (String text : texts) {
            TeXFormula formula = new TeXFormula("\\text{ " + text + "}");
            TeXIcon icon = formula.new TeXIconBuilder().setStyle(TeXConstants.STYLE_DISPLAY)
                    .setSize(16)
                    .setWidth(TeXConstants.UNIT_PIXEL, 256f, TeXConstants.ALIGN_CENTER)
                    .setIsMaxWidth(true).setInterLineSpacing(TeXConstants.UNIT_PIXEL, 20f)
                    .build();

            JLabel jl = new JLabel(icon);
            jl.setBorder(BorderFactory.createLineBorder(Color.BLACK));

            contentPane.add(jl);
        }

        jf.pack();
        jf.setVisible(true);
    }

}

Please, refer to this full example. Line breaks is supported by jLatexMath - however it doesn't work on the chinese utf-8 whitespace symbols. Furthermore - in XeLatex, when using the \usepackage{xeCJK} package - it breaks even on word symbols.

from jlatexmath.

murkle avatar murkle commented on August 12, 2024

Sorry, not sure what you mean by "chinese utf-8 whitespace symbols" - what is the Unicode number for those?

from jlatexmath.

murkle avatar murkle commented on August 12, 2024

BTW setIsMaxWidth() isn't present any more in the currently developed version (https://github.com/opencollab/jlatexmath/blob/experimental/jlatexmath/src/main/java/org/scilab/forge/jlatexmath/share/TeXFormula.java )

from jlatexmath.

fnatter avatar fnatter commented on August 12, 2024

BTW setIsMaxWidth() isn't present any more in the currently developed version (https://github.com/opencollab/jlatexmath/blob/experimental/jlatexmath/src/main/java/org/scilab/forge/jlatexmath/share/TeXFormula.java )

hello murkle,
thanks for the heads-up!

it looks like we need to set a length in the TeXEnvironment in order to get automatic line breaking:

https://github.com/opencollab/jlatexmath/blob/experimental/jlatexmath/src/main/java/org/scilab/forge/jlatexmath/share/TeXFormula.java#L429

Is experimental the branch leading up to 2.0 or 1.0.8?

Cheers and Best Regards,
Felix

from jlatexmath.

murkle avatar murkle commented on August 12, 2024

experimental == v2.0

from jlatexmath.

BeniaminK avatar BeniaminK commented on August 12, 2024

Sorry, not sure what you mean by "chinese utf-8 whitespace symbols" - what is the Unicode number for those?

U+3000, U+3001, U+3002, U+300C, U+300D and many many more. I don't think it's even possible to list them all in fact (I'm not that familiar with ideographic characters).

However the solution that breaks the lines at characters might work well too as it would add a line breaks for the cases above too. (maybe as an optional flag)

from jlatexmath.

murkle avatar murkle commented on August 12, 2024

I agree that https://www.fileformat.info/info/unicode/char/3000/index.htm is whitespace but not https://www.fileformat.info/info/unicode/char/3001/index.htm - that's a comma

I don't think you'd want to break on https://www.fileformat.info/info/unicode/char/300c/index.htm

You can use Character.isWhitespace() https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html

If that's not what you want then you'll need to compile a full list of what you do want to break on as a first step

from jlatexmath.

pablogzlezmora avatar pablogzlezmora commented on August 12, 2024

Does the JLaTeXMath of GeoGebra have auto linebreak?

from jlatexmath.

murkle avatar murkle commented on August 12, 2024

Nope

from jlatexmath.

pablogzlezmora avatar pablogzlezmora commented on August 12, 2024

Thanks, Michael. :-(

from jlatexmath.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.