Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

Any specification that MapAt accepts can be used for parameter pos:

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 2 ;; -3 ;; 3]

enter image description here

However the function cannot be applied to more than once, or to an already styled string:

stringBold[%, 3]  (* failure *)

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

Any specification that MapAt accepts can be used for parameter pos:

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 2 ;; -3 ;; 3]

enter image description here

However the function cannot be applied to more than once, or to an already styled string:

stringBold[%, 3]  (* failure *)

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

Any specification that MapAt accepts can be used for parameter pos:

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 2 ;; -3 ;; 3]

enter image description here

However the function cannot be applied to more than once, or to an already styled string:

stringBold[%, 3]  (* failure *)
added 356 characters in body
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_Integer]pos_] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

Any specification that MapAt accepts can be used for parameter pos:

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 2 ;; -3 ;; 3]

enter image description here

However the function cannot be applied to more than once, or to an already styled string:

stringBold[%, 3]  (* failure *)

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_Integer] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"

Any specification that MapAt accepts can be used for parameter pos:

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 2 ;; -3 ;; 3]

enter image description here

However the function cannot be applied to more than once, or to an already styled string:

stringBold[%, 3]  (* failure *)
Source Link
Mr.Wizard
  • 273.1k
  • 34
  • 595
  • 1.4k

This question is related to at least:

Fortunately it is simpler than the first one and we can apply the methods provided in the second one.

stringBold[s_String, pos_Integer] :=
 "" <> MapAt[Style[#, Bold] ~ToString~ StandardForm &, Characters@s, pos]

stringBold["CDABOZPVRYXSWQEGNILUTHMKJF", 7]

enter image description here

The output is a String with and embedded Box form:

% // InputForm
"CDABOZ\!\(\*StyleBox[\"\\\"P\\\"\", Bold, Rule[StripOnInput, \
False]]\)VRYXSWQEGNILUTHMKJF"