How to set the font color of quantity objects (Version 11.3 vs version 12)How can I set the background color to the Popupmenu?How to get and set default font parameters for Plot, ListPlot, LogPlot, etc.?Change base font for all graphics objectsChange Default Font Color of CommandsHow to change the font color and size of tick labels by defaultFont presentation difference between version 9 and version 10How to change the texture of the graphical objects?Remove color artifacts in overlay of several Graphics objects?How to query the properties of objects?Can MaTeX objects scale the same way as Text objects?

Stop and Take a Breath!

Executing a stored procedure which selects and inserts into tables in SQL Server

How to set the font color of quantity objects (Version 11.3 vs version 12)

Do I have to worry about players making “bad” choices on level up?

Was there a shared-world project before "Thieves World"?

How can the Zone of Truth spell be defeated without the caster knowing?

Inner for loop when run in background in bash spawns new bash process

How do I deal with a coworker that keeps asking to make small superficial changes to a report, and it is seriously triggering my anxiety?

Will tsunami waves travel forever if there was no land?

Examples of non trivial equivalence relations , I mean equivalence relations without the expression " same ... as" in their definition?

Will a top journal at least read my introduction?

How can I practically buy stocks?

How to delegate to implementing class

How would one muzzle a full grown polar bear in the 13th century?

How to verbalise code in Mathematica?

Is thermodynamics only applicable to systems in equilibrium?

What does KSP mean?

Short story about a planet with two sentient species

Confused by chemical notation

Any examples of headwear for races with animal ears?

Is DC-to-DC (24 V to 12 V) buck conversion typically more efficient than AC-to-DC (110 V to 12 V) conversion?

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

Unexpected email from Yorkshire Bank

With a Canadian student visa, can I spend a night at Vancouver before continuing to Toronto?



How to set the font color of quantity objects (Version 11.3 vs version 12)


How can I set the background color to the Popupmenu?How to get and set default font parameters for Plot, ListPlot, LogPlot, etc.?Change base font for all graphics objectsChange Default Font Color of CommandsHow to change the font color and size of tick labels by defaultFont presentation difference between version 9 and version 10How to change the texture of the graphical objects?Remove color artifacts in overlay of several Graphics objects?How to query the properties of objects?Can MaTeX objects scale the same way as Text objects?













2












$begingroup$


TD = 8 + 12 + 12 + 12 + 33 + (61 + 1/4) + (41 + 1/4)/2 + 
15/2 + (18 + 3/4) + (18 + 3/4)/2 + 14/2;
CM = 15/2 + (61 + 1/4) + (41 + 1/4)/2 +
24 + (3 + 3/4) + (18 + 3/4) + (18 + 3/4)/2 + 14/2 + (24 + 3/4) +
9/2;
TP = 2*90;

countsDim1 = CM, TD, TP/(TD + TP + CM)

n = 384 + 179;
labels = Placed[
Row /@ Thread["" <> ToString@# <>
" H" & /@ N[(n countsDim1[[1]]), 5],
N[(n countsDim1[[2]]), 5], Round@N[(n countsDim1)[[3]]]],
"RadialOuter"];
legend = Placed[
SwatchLegend[Automatic,
Row /@ Thread["CM ", "TD ", "TP ",
Row["(", #, , ")"] & /@
Quantity[Round[100 countsDim1], "Percent"]],
LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
FontColor -> Black, FontWeight -> Bold,
LegendMarkerSize -> 26], After, Bottom, Framed];

type = Framed[
PieChart[countsDim1, ChartLabels -> labels, ChartLegends -> legend,
PlotRange -> All,
LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
FontColor -> White, FontWeight -> Bold, PlotTheme -> "Business",
ImageSize -> Medium], Background -> LightGreen]


In Mathematica 11.3 above code would produce a Pie Chart with the percentage of the Legend black. In Mathematica 12, I get the text of the percentage with gray color.



Version 12



Below the same figure with Mathematica 11.3 (albeit without the bold text of the LegendLabel)



Version 11.3



What is different in Mathematica 12?



How can I get the percentage in black color (and bold)?










share|improve this question











$endgroup$
















    2












    $begingroup$


    TD = 8 + 12 + 12 + 12 + 33 + (61 + 1/4) + (41 + 1/4)/2 + 
    15/2 + (18 + 3/4) + (18 + 3/4)/2 + 14/2;
    CM = 15/2 + (61 + 1/4) + (41 + 1/4)/2 +
    24 + (3 + 3/4) + (18 + 3/4) + (18 + 3/4)/2 + 14/2 + (24 + 3/4) +
    9/2;
    TP = 2*90;

    countsDim1 = CM, TD, TP/(TD + TP + CM)

    n = 384 + 179;
    labels = Placed[
    Row /@ Thread["" <> ToString@# <>
    " H" & /@ N[(n countsDim1[[1]]), 5],
    N[(n countsDim1[[2]]), 5], Round@N[(n countsDim1)[[3]]]],
    "RadialOuter"];
    legend = Placed[
    SwatchLegend[Automatic,
    Row /@ Thread["CM ", "TD ", "TP ",
    Row["(", #, , ")"] & /@
    Quantity[Round[100 countsDim1], "Percent"]],
    LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
    FontColor -> Black, FontWeight -> Bold,
    LegendMarkerSize -> 26], After, Bottom, Framed];

    type = Framed[
    PieChart[countsDim1, ChartLabels -> labels, ChartLegends -> legend,
    PlotRange -> All,
    LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
    FontColor -> White, FontWeight -> Bold, PlotTheme -> "Business",
    ImageSize -> Medium], Background -> LightGreen]


    In Mathematica 11.3 above code would produce a Pie Chart with the percentage of the Legend black. In Mathematica 12, I get the text of the percentage with gray color.



    Version 12



    Below the same figure with Mathematica 11.3 (albeit without the bold text of the LegendLabel)



    Version 11.3



    What is different in Mathematica 12?



    How can I get the percentage in black color (and bold)?










    share|improve this question











    $endgroup$














      2












      2








      2





      $begingroup$


      TD = 8 + 12 + 12 + 12 + 33 + (61 + 1/4) + (41 + 1/4)/2 + 
      15/2 + (18 + 3/4) + (18 + 3/4)/2 + 14/2;
      CM = 15/2 + (61 + 1/4) + (41 + 1/4)/2 +
      24 + (3 + 3/4) + (18 + 3/4) + (18 + 3/4)/2 + 14/2 + (24 + 3/4) +
      9/2;
      TP = 2*90;

      countsDim1 = CM, TD, TP/(TD + TP + CM)

      n = 384 + 179;
      labels = Placed[
      Row /@ Thread["" <> ToString@# <>
      " H" & /@ N[(n countsDim1[[1]]), 5],
      N[(n countsDim1[[2]]), 5], Round@N[(n countsDim1)[[3]]]],
      "RadialOuter"];
      legend = Placed[
      SwatchLegend[Automatic,
      Row /@ Thread["CM ", "TD ", "TP ",
      Row["(", #, , ")"] & /@
      Quantity[Round[100 countsDim1], "Percent"]],
      LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
      FontColor -> Black, FontWeight -> Bold,
      LegendMarkerSize -> 26], After, Bottom, Framed];

      type = Framed[
      PieChart[countsDim1, ChartLabels -> labels, ChartLegends -> legend,
      PlotRange -> All,
      LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
      FontColor -> White, FontWeight -> Bold, PlotTheme -> "Business",
      ImageSize -> Medium], Background -> LightGreen]


      In Mathematica 11.3 above code would produce a Pie Chart with the percentage of the Legend black. In Mathematica 12, I get the text of the percentage with gray color.



      Version 12



      Below the same figure with Mathematica 11.3 (albeit without the bold text of the LegendLabel)



      Version 11.3



      What is different in Mathematica 12?



      How can I get the percentage in black color (and bold)?










      share|improve this question











      $endgroup$




      TD = 8 + 12 + 12 + 12 + 33 + (61 + 1/4) + (41 + 1/4)/2 + 
      15/2 + (18 + 3/4) + (18 + 3/4)/2 + 14/2;
      CM = 15/2 + (61 + 1/4) + (41 + 1/4)/2 +
      24 + (3 + 3/4) + (18 + 3/4) + (18 + 3/4)/2 + 14/2 + (24 + 3/4) +
      9/2;
      TP = 2*90;

      countsDim1 = CM, TD, TP/(TD + TP + CM)

      n = 384 + 179;
      labels = Placed[
      Row /@ Thread["" <> ToString@# <>
      " H" & /@ N[(n countsDim1[[1]]), 5],
      N[(n countsDim1[[2]]), 5], Round@N[(n countsDim1)[[3]]]],
      "RadialOuter"];
      legend = Placed[
      SwatchLegend[Automatic,
      Row /@ Thread["CM ", "TD ", "TP ",
      Row["(", #, , ")"] & /@
      Quantity[Round[100 countsDim1], "Percent"]],
      LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
      FontColor -> Black, FontWeight -> Bold,
      LegendMarkerSize -> 26], After, Bottom, Framed];

      type = Framed[
      PieChart[countsDim1, ChartLabels -> labels, ChartLegends -> legend,
      PlotRange -> All,
      LabelStyle -> FontSize -> 26, FontFamily -> "Latin Modern Roman",
      FontColor -> White, FontWeight -> Bold, PlotTheme -> "Business",
      ImageSize -> Medium], Background -> LightGreen]


      In Mathematica 11.3 above code would produce a Pie Chart with the percentage of the Legend black. In Mathematica 12, I get the text of the percentage with gray color.



      Version 12



      Below the same figure with Mathematica 11.3 (albeit without the bold text of the LegendLabel)



      Version 11.3



      What is different in Mathematica 12?



      How can I get the percentage in black color (and bold)?







      graphics version-12






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 17 mins ago







      Dimitris

















      asked 5 hours ago









      DimitrisDimitris

      2,3691332




      2,3691332




















          2 Answers
          2






          active

          oldest

          votes


















          2












          $begingroup$

          I don't know why it was visualized like that in Mathematica 11.3, but generally speaking, styling can be affected when you plot objects like entities, quantities, etc. instead of their corresponding strings. To be fully in control of the styling, I would suggest converting the quantity to a number.



          I suggest replacing



          Row["(", #, , ")"]


          with



          Row["(", QuantityMagnitude[#], "%)"]





          share|improve this answer









          $endgroup$




















            2












            $begingroup$

            Looks like a bug to me:



            In version 12.0, the typesetting of Quantity objects in TraditionalForm (which is used for legends in Legended expressions) breaks after typesetting a quantity with the same unit in StandardForm. To see this, consider the following example: (use a fresh kernel)



            TraditionalForm@Quantity[3.5, "Percent"]
            Quantity[3.5, "Percent"]
            TraditionalForm@Quantity[3.5, "Percent"]
            TraditionalForm@Quantity[1, "Percent"]


            enter image description here



            As you can see, quantities are typeset differently in TraditionalForm, and the one for TraditionalForm changes after typesetting in StandardForm once. The case of 1 is handled differently for some reason and does not break.



            In 11.3, the typesetting of the TraditionalForm variant does not break after typesetting the StandardForm variant. This is why your example works in 11.3: The style for TraditionalForm does not set the FontColor, while the StandardForm one does (see CurrentValue[StyleDefinitions, "QuantityPanel"], which is only used for StandardForm). That this works seems like a lucky coincidence, so I would suggest to use the method from @C.E.'s answer anyway, even if this gets fixed.



            Tracking down the issue



            The issue is caused by a change to the caching used for quantity typesetting:



            (* cache lookup in 11.3 typesetting code for Quantity *)
            QuantityUnits`QuantityBox[
            Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form:StandardForm]
            ] :=
            Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]

            (* cache lookup in 12.0 typesetting code for Quantity *)
            QuantityUnits`QuantityBox[
            Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form_:StandardForm]
            ] :=
            Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]


            Note the change from form:StandardForm to form_:StandardForm - this extends the caching from StandardForm to all forms. The reason I think this is a bug is that this is the only definition of QuantityBox that defaults form to anything (all the others require an explicit form to be given), which suggests someone "fixed" a typo.



            The issue with the caching code is that it ignores form when performing the cache lookup. Writing to the cache still requires StandardForm (here, the form:StandardForm pattern is still present in 12.0). The code was already questionable in 11.3 (since the caching partially supports forms other than StandardForm), but this was not an issue since it was only ever called with StandardForm.






            share|improve this answer









            $endgroup$












            • $begingroup$
              Should I change the title of the question since it is misleading?
              $endgroup$
              – Dimitris
              33 mins ago










            • $begingroup$
              Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
              $endgroup$
              – Lukas Lang
              21 mins ago











            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197228%2fhow-to-set-the-font-color-of-quantity-objects-version-11-3-vs-version-12%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2












            $begingroup$

            I don't know why it was visualized like that in Mathematica 11.3, but generally speaking, styling can be affected when you plot objects like entities, quantities, etc. instead of their corresponding strings. To be fully in control of the styling, I would suggest converting the quantity to a number.



            I suggest replacing



            Row["(", #, , ")"]


            with



            Row["(", QuantityMagnitude[#], "%)"]





            share|improve this answer









            $endgroup$

















              2












              $begingroup$

              I don't know why it was visualized like that in Mathematica 11.3, but generally speaking, styling can be affected when you plot objects like entities, quantities, etc. instead of their corresponding strings. To be fully in control of the styling, I would suggest converting the quantity to a number.



              I suggest replacing



              Row["(", #, , ")"]


              with



              Row["(", QuantityMagnitude[#], "%)"]





              share|improve this answer









              $endgroup$















                2












                2








                2





                $begingroup$

                I don't know why it was visualized like that in Mathematica 11.3, but generally speaking, styling can be affected when you plot objects like entities, quantities, etc. instead of their corresponding strings. To be fully in control of the styling, I would suggest converting the quantity to a number.



                I suggest replacing



                Row["(", #, , ")"]


                with



                Row["(", QuantityMagnitude[#], "%)"]





                share|improve this answer









                $endgroup$



                I don't know why it was visualized like that in Mathematica 11.3, but generally speaking, styling can be affected when you plot objects like entities, quantities, etc. instead of their corresponding strings. To be fully in control of the styling, I would suggest converting the quantity to a number.



                I suggest replacing



                Row["(", #, , ")"]


                with



                Row["(", QuantityMagnitude[#], "%)"]






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 hours ago









                C. E.C. E.

                51.5k3101207




                51.5k3101207





















                    2












                    $begingroup$

                    Looks like a bug to me:



                    In version 12.0, the typesetting of Quantity objects in TraditionalForm (which is used for legends in Legended expressions) breaks after typesetting a quantity with the same unit in StandardForm. To see this, consider the following example: (use a fresh kernel)



                    TraditionalForm@Quantity[3.5, "Percent"]
                    Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[1, "Percent"]


                    enter image description here



                    As you can see, quantities are typeset differently in TraditionalForm, and the one for TraditionalForm changes after typesetting in StandardForm once. The case of 1 is handled differently for some reason and does not break.



                    In 11.3, the typesetting of the TraditionalForm variant does not break after typesetting the StandardForm variant. This is why your example works in 11.3: The style for TraditionalForm does not set the FontColor, while the StandardForm one does (see CurrentValue[StyleDefinitions, "QuantityPanel"], which is only used for StandardForm). That this works seems like a lucky coincidence, so I would suggest to use the method from @C.E.'s answer anyway, even if this gets fixed.



                    Tracking down the issue



                    The issue is caused by a change to the caching used for quantity typesetting:



                    (* cache lookup in 11.3 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]

                    (* cache lookup in 12.0 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form_:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]


                    Note the change from form:StandardForm to form_:StandardForm - this extends the caching from StandardForm to all forms. The reason I think this is a bug is that this is the only definition of QuantityBox that defaults form to anything (all the others require an explicit form to be given), which suggests someone "fixed" a typo.



                    The issue with the caching code is that it ignores form when performing the cache lookup. Writing to the cache still requires StandardForm (here, the form:StandardForm pattern is still present in 12.0). The code was already questionable in 11.3 (since the caching partially supports forms other than StandardForm), but this was not an issue since it was only ever called with StandardForm.






                    share|improve this answer









                    $endgroup$












                    • $begingroup$
                      Should I change the title of the question since it is misleading?
                      $endgroup$
                      – Dimitris
                      33 mins ago










                    • $begingroup$
                      Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                      $endgroup$
                      – Lukas Lang
                      21 mins ago















                    2












                    $begingroup$

                    Looks like a bug to me:



                    In version 12.0, the typesetting of Quantity objects in TraditionalForm (which is used for legends in Legended expressions) breaks after typesetting a quantity with the same unit in StandardForm. To see this, consider the following example: (use a fresh kernel)



                    TraditionalForm@Quantity[3.5, "Percent"]
                    Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[1, "Percent"]


                    enter image description here



                    As you can see, quantities are typeset differently in TraditionalForm, and the one for TraditionalForm changes after typesetting in StandardForm once. The case of 1 is handled differently for some reason and does not break.



                    In 11.3, the typesetting of the TraditionalForm variant does not break after typesetting the StandardForm variant. This is why your example works in 11.3: The style for TraditionalForm does not set the FontColor, while the StandardForm one does (see CurrentValue[StyleDefinitions, "QuantityPanel"], which is only used for StandardForm). That this works seems like a lucky coincidence, so I would suggest to use the method from @C.E.'s answer anyway, even if this gets fixed.



                    Tracking down the issue



                    The issue is caused by a change to the caching used for quantity typesetting:



                    (* cache lookup in 11.3 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]

                    (* cache lookup in 12.0 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form_:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]


                    Note the change from form:StandardForm to form_:StandardForm - this extends the caching from StandardForm to all forms. The reason I think this is a bug is that this is the only definition of QuantityBox that defaults form to anything (all the others require an explicit form to be given), which suggests someone "fixed" a typo.



                    The issue with the caching code is that it ignores form when performing the cache lookup. Writing to the cache still requires StandardForm (here, the form:StandardForm pattern is still present in 12.0). The code was already questionable in 11.3 (since the caching partially supports forms other than StandardForm), but this was not an issue since it was only ever called with StandardForm.






                    share|improve this answer









                    $endgroup$












                    • $begingroup$
                      Should I change the title of the question since it is misleading?
                      $endgroup$
                      – Dimitris
                      33 mins ago










                    • $begingroup$
                      Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                      $endgroup$
                      – Lukas Lang
                      21 mins ago













                    2












                    2








                    2





                    $begingroup$

                    Looks like a bug to me:



                    In version 12.0, the typesetting of Quantity objects in TraditionalForm (which is used for legends in Legended expressions) breaks after typesetting a quantity with the same unit in StandardForm. To see this, consider the following example: (use a fresh kernel)



                    TraditionalForm@Quantity[3.5, "Percent"]
                    Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[1, "Percent"]


                    enter image description here



                    As you can see, quantities are typeset differently in TraditionalForm, and the one for TraditionalForm changes after typesetting in StandardForm once. The case of 1 is handled differently for some reason and does not break.



                    In 11.3, the typesetting of the TraditionalForm variant does not break after typesetting the StandardForm variant. This is why your example works in 11.3: The style for TraditionalForm does not set the FontColor, while the StandardForm one does (see CurrentValue[StyleDefinitions, "QuantityPanel"], which is only used for StandardForm). That this works seems like a lucky coincidence, so I would suggest to use the method from @C.E.'s answer anyway, even if this gets fixed.



                    Tracking down the issue



                    The issue is caused by a change to the caching used for quantity typesetting:



                    (* cache lookup in 11.3 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]

                    (* cache lookup in 12.0 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form_:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]


                    Note the change from form:StandardForm to form_:StandardForm - this extends the caching from StandardForm to all forms. The reason I think this is a bug is that this is the only definition of QuantityBox that defaults form to anything (all the others require an explicit form to be given), which suggests someone "fixed" a typo.



                    The issue with the caching code is that it ignores form when performing the cache lookup. Writing to the cache still requires StandardForm (here, the form:StandardForm pattern is still present in 12.0). The code was already questionable in 11.3 (since the caching partially supports forms other than StandardForm), but this was not an issue since it was only ever called with StandardForm.






                    share|improve this answer









                    $endgroup$



                    Looks like a bug to me:



                    In version 12.0, the typesetting of Quantity objects in TraditionalForm (which is used for legends in Legended expressions) breaks after typesetting a quantity with the same unit in StandardForm. To see this, consider the following example: (use a fresh kernel)



                    TraditionalForm@Quantity[3.5, "Percent"]
                    Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[3.5, "Percent"]
                    TraditionalForm@Quantity[1, "Percent"]


                    enter image description here



                    As you can see, quantities are typeset differently in TraditionalForm, and the one for TraditionalForm changes after typesetting in StandardForm once. The case of 1 is handled differently for some reason and does not break.



                    In 11.3, the typesetting of the TraditionalForm variant does not break after typesetting the StandardForm variant. This is why your example works in 11.3: The style for TraditionalForm does not set the FontColor, while the StandardForm one does (see CurrentValue[StyleDefinitions, "QuantityPanel"], which is only used for StandardForm). That this works seems like a lucky coincidence, so I would suggest to use the method from @C.E.'s answer anyway, even if this gets fixed.



                    Tracking down the issue



                    The issue is caused by a change to the caching used for quantity typesetting:



                    (* cache lookup in 11.3 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]

                    (* cache lookup in 12.0 typesetting code for Quantity *)
                    QuantityUnits`QuantityBox[
                    Quantity[n_, unit_?QuantityUnits`Private`UnitDisplayCacheContainsQ], form_:StandardForm]
                    ] :=
                    Quiet[QuantityUnits`Private`getUnitDisplayForm[unit, n, form], Part::partw]


                    Note the change from form:StandardForm to form_:StandardForm - this extends the caching from StandardForm to all forms. The reason I think this is a bug is that this is the only definition of QuantityBox that defaults form to anything (all the others require an explicit form to be given), which suggests someone "fixed" a typo.



                    The issue with the caching code is that it ignores form when performing the cache lookup. Writing to the cache still requires StandardForm (here, the form:StandardForm pattern is still present in 12.0). The code was already questionable in 11.3 (since the caching partially supports forms other than StandardForm), but this was not an issue since it was only ever called with StandardForm.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 1 hour ago









                    Lukas LangLukas Lang

                    7,49011032




                    7,49011032











                    • $begingroup$
                      Should I change the title of the question since it is misleading?
                      $endgroup$
                      – Dimitris
                      33 mins ago










                    • $begingroup$
                      Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                      $endgroup$
                      – Lukas Lang
                      21 mins ago
















                    • $begingroup$
                      Should I change the title of the question since it is misleading?
                      $endgroup$
                      – Dimitris
                      33 mins ago










                    • $begingroup$
                      Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                      $endgroup$
                      – Lukas Lang
                      21 mins ago















                    $begingroup$
                    Should I change the title of the question since it is misleading?
                    $endgroup$
                    – Dimitris
                    33 mins ago




                    $begingroup$
                    Should I change the title of the question since it is misleading?
                    $endgroup$
                    – Dimitris
                    33 mins ago












                    $begingroup$
                    Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                    $endgroup$
                    – Lukas Lang
                    21 mins ago




                    $begingroup$
                    Well, it describes the original issue you were having - you could change it to "How to set the font color of quantity objects" to make it a bit more descriptive. This answer was more intended as an explanation of what changed, rather than as a direct solution to your problem
                    $endgroup$
                    – Lukas Lang
                    21 mins ago

















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f197228%2fhow-to-set-the-font-color-of-quantity-objects-version-11-3-vs-version-12%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

                    Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

                    How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2