Jabref: LaTeX `\textit{..}` is not redered correctly in Main table

Created on 26 Oct 2017  路  26Comments  路  Source: JabRef/jabref

Entry to reproduce:

@Article{Abdala2007,
  author    = {Fernando Abdala},
  title     = {{{Redescription} {of} \textit{Platycraniellus elegans} ({Therapsida}, {Cynodontia}) {from} {the} {Lower} {Triassic} {of} {South} {Africa}, {and} {the} {cladistic} {relationships} {of} {eutheriodonts}}},
  journal   = {Palaeontology},
  year      = {2007},
  volume    = {50},
  number    = {3},
  pages     = {591--618},
  month     = {may},
  doi       = {10.1111/j.1475-4983.2007.00646.x},
  file      = {Abdala2007.pdf:Abdala2007.pdf:PDF},
  groups    = {Nanictosaurus, Ictidosuchoides},
  keywords  = {Platycraniellus elegans, Cynodontia, galesaurids, Early Triassic, South Africa.},
  publisher = {Wiley-Blackwell},
  url       = {http://dx.doi.org/10.1111/j.1475-4983.2007.00646.x},
}

Gives the following representation in the main table

screen shot 2017-10-26 at 12 38 55

The Preview is not affected.

MacOS Sierra 10.12.6
JabRef current master branch
Mac OS X 10.12.6 x86_64 
Java 1.8.0_144
maintable ui

Most helpful comment

Feel free to take any open issue you want.
We still have enough for everyone 馃槈馃槣
Easy beginner issues are also tagged with the good first issue label

All 26 comments

This issue seems not related to JabRef. It is related to JLabel and Swing. A minimal working example can be found here (I'll attach the code below). I'm not setting any different font or font size. Still, what I get is

screen shot 2017-10-26 at 14 37 44

Note that I see the correctly rendered label in the debugger. So the Unicode conversion is correct

screen shot 2017-10-26 at 14 38 53

There are several similar issues on SO but none fits to such a simple example. Can someone on OS X try this by creating a class in the jabref package and pasting the content?

package org.jabref;


import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import org.jabref.model.strings.LatexToUnicodeAdapter;

public class SwingJLabelTester extends JPanel{

    private SwingJLabelTester() {
        super(new GridLayout(3,1));  //3 rows, 1 column
        final String latexString = LatexToUnicodeAdapter.format("This is a \\textit{test for italics} and \\textbf{a test for bold}");
        final JLabel label = new JLabel(latexString, SwingConstants.CENTER);
        label.setVerticalTextPosition(SwingConstants.BOTTOM);
        label.setHorizontalTextPosition(SwingConstants.CENTER);
        add(label);
    }

    private static void createAndShowGUI() {
        final JFrame frame = new JFrame("LabelDemo");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(new SwingJLabelTester());
        frame.setSize(400,400);
        frame.setVisible(true);
    }

    public static void main(final String[] args) {
        SwingUtilities.invokeLater(SwingJLabelTester::createAndShowGUI);
    }

}

The problem reminded me of the issue https://github.com/JabRef/jabref/issues/2784 and the follow up discussion we had on this.

See discussion here:
https://github.com/JabRef/jabref/issues/2784
here:
https://github.com/JabRef/jabref/pull/2752
and here:
https://github.com/JabRef/jabref/pull/3008

I thought this was fixed with https://github.com/JabRef/jabref/pull/3008, but I encounter this issue again in:
JabRef 4.1-dev--snapshot--2017-10-23--master--451b6f3de
Windows 10 10.0 amd64
Java 1.8.0_151

Could it be that when reinstalling a new version of JabRef, old preferences for system fonts are imported, which cause the issue (see also https://github.com/JabRef/jabref/pull/3008)?

@Siedlerchr @AEgit Oh god, this is a lot of information. I only skimmed over some issues to see if this has been reported recently. This quote from @lenhard

Before that change, you could have italics in the main table with the right font. Now, I can't find one that supports it.

It was my first guess as well and I tried different settings but nothing helped. That's why I implemented the test-class. Additionally, I read through some SO posts and finally asked with this minimal example here.

When it is indeed a font issue that comes and goes with setting different fonts it would be bad since users can change this as they like. Since the main table is only displayed and not edited directly, would it be an option to use HTML like we do in the preview?

HTML could be an option, should be possible, https://docs.oracle.com/javase/tutorial/uiswing/components/html.html
In JabRef all MainTable stuff is in the org.jabref.gui.maintable package

Maybe a stupid question: Was there a reason for why HTML wasn't used in the first place for the main table? Could this influence the performance in large databases?

The first time I started (after new installation)

JabRef 4.1-dev--snapshot--2017-10-26--master--3d4b5104d
Windows 10 10.0 amd64
Java 1.8.0_151

this issue seemed to be fixed, i. e. the \textit{} was interpreted correctly and text appeared in italics in the main table.

The second time I started the same JabRef version, the issue reported above reappeared, i. e. text that should render in italics is replaced by squares in the main table. This issue persists when restarting JabRef. This indicates, I guess, that something changes in the default settings between the first installation of JabRef and subsequent use.

We could use the latex2html converter, similar as in #3574

This should be fixed in the latest development version. Could you please check the build from https://builds.jabref.org/maintable-beta/. Thanks! Note this version is in a very early beta stage and might not work as expected. See https://github.com/JabRef/jabref/pull/3621 for further details.

I can confirm that this has been fixed in:

JabRef 4.2-dev--snapshot--2018-01-30--maintable-beta--85342350f
Windows 10 10.0 amd64
Java 1.8.0_161

Thank you for your help!

Note, however, that the performance of the search has dropped significantly in the new build and other issues appear to persist (see https://github.com/JabRef/jabref/issues/1513#issuecomment-361528430).

Unfortunately, the problem still exists with JabRef_windows-x64_4_2-dev--snapshot--2018-02-05--master--e33bd5888 and Windows 8.1 with JRE 8 (Update 166).
Interstingly, it works with Win10.

@tolot27 You are using the wrong branch. This is not yet in master, but in the maintable-beta branch linked by @tobiasdiez above.

I've tried the maintable-beta branch but the problem persists.

As the discussion in #4236 shows, more users have problems with italics even with the new master branch. I'll thus reopen it. Probably, it depends on the active (system?) font.

Cannot reproduce this issue for:

JabRef 5.0-dev--snapshot--2018-07-25--master--077fdacc2
Windows 10 10.0 amd64
Java 1.8.0_181

Note, however, my post here: https://github.com/JabRef/jabref/issues/3356#issuecomment-339913701
If this issue exists, it might be difficult to reproduce it consistently if it has to do with the way JabRef is closed/the database is saved. I have tried to reopen my database multiple times and did not encounter the issue, but I cannot guarantee, that this is the case for everyone.

I tested it with 4.3.1 and 5.0-dev--snapshot--2018-07-25--master--077fdacc2 and cannot reproduce the bug anymore.

It might be a font Unicode issue on older Windows Versions.

It would be nice if someone of the Mac or Linux user can check that as well.

@Siedlerchr In Linux, with Java 1.7u162 this works for me. If someone wonders how to quickly use the test-code that I provide here in IDEA:

  1. Copy the code
  2. Have the JabRef project open
  3. Create a new scratch file using Ctrl+Shift+A and type scratch. Select Java
  4. Paste the code in there, go over the class error and press Alt+Enter to rename the file to the class name
  5. Use the small "run" button on the left side, next to the main method

It should look like this

img

Although I don't see a vast difference between plain and bold text, at least I have no missing characters.

Thanks for the test, but are you aware that it runs completely on JavaFX now (maintable and entry editor)?

I think we can close this again, as windows 7 specific

@Siedlerchr this "problem" might still exists in Mac OS X.

Ska虉rmavbild 2020-05-28 kl  13 33 12

I have managed to get some inconsistent behaviours on this one (sometimes italic and bold works as expected and sometimes not at all, and sometimes like on the screenshot, it partially works).

Should I open up a new issue or is this better solved in some other way?

Version of screenshot is
JabRef 5.1--2020-05-28--ffa07cd
Mac OS X 10.15.5 x86_64
Java 14.0.1

red highlights are added by me

For the author/editor field it's not that relevant, title or any other fields are more important

Maybe related: https://docs.jabref.org/installation#some-characters-are-not-displayed-in-the-main-table-math-characters-or-some-upper-cased-letter

I could look at it tomorrow, the behaviour is the same/similar in author/title and I can get it to both work/break, the only difference between the 2 screenshots are a resizing event.

Ska虉rmavbild 2020-05-28 kl  14 38 21

Ska虉rmavbild 2020-05-28 kl  14 38 37

Also note that the preview in the bottom right doesn't display the same thing as the maintable. Even if this is just a Mac OS X "thing", does it seem reasonable that I take a closer look at it?

@k3KAW8Pnf7mkmdSMPHz27 The entry preview is controlled over html code in the preferences under Entry preview. It's essentially a web browser component. (WebView)
The main table uses plain Unicode as it does not support html formatting,

I guess there is something wrong with the latex2unicode parsing as well
And tip: you can also make the preview a new tab in the entry editor

And tip: you can also make the preview a new tab in the entry editor
I see 馃榾

I'll not put more time into this then, I am off to find some more beginner friendly issue to tackle 馃槑

Feel free to take any open issue you want.
We still have enough for everyone 馃槈馃槣
Easy beginner issues are also tagged with the good first issue label

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oscargus picture oscargus  路  3Comments

c3h899 picture c3h899  路  3Comments

tobiasdiez picture tobiasdiez  路  4Comments

lenhard picture lenhard  路  4Comments

tobiasdiez picture tobiasdiez  路  4Comments