3
$\begingroup$

I am preparing a practical class of physics in which I need to justify the following text that is very extensive. But when I use StringSplit or MapAt to highlight certain important words, I do not get a justified text and I do not know what to do. The code is the following:

text = Style[#, Bold, FontFamily -> "Comic Sans MS", 24] & /@ 
   StringSplit[
    "En este tipo de difracción, las distancias fuente-objeto, ojeto-pantalla son grandes lo que implica que las ondas se pueden representar como  lineas paralelas en la dirección de propagación de sus frentes.La difracción de Fraunhoffer no permite obtener una condición de máximo y una de mínimo al estilo de las obtenidas para la interferencia, por ello se trabaja de forma especial con los casos de una rendija y múltiples rendijas, ya que no se pueden contar las ondas coherentes que se superponen porque la distribución continua de las fuentes luminosas y la superposición de las ondas en un punto     dado se refleja matemáticamente por una integral. (Óptica Ondulatoria, Héctor León,pág.373)"
];

TextCell[
  Row[  
    MapAt[Style[#, Bold, 24, Red] &, text, {{21 ;; 31}, {54}, {60 ;; 80}}], 
    Spacer[5]
  ], 
  TextJustification -> 1
]
$\endgroup$
3
  • $\begingroup$ Can you comment on my answer? $\endgroup$
    – Kuba
    Commented Dec 11, 2018 at 7:33
  • $\begingroup$ Thank you for answering my question and thanks again because your code has allowed me to finish my class on time, your help has been of great value to me. $\endgroup$
    – Andres
    Commented Dec 11, 2018 at 13:20
  • $\begingroup$ I am glad I could help :) $\endgroup$
    – Kuba
    Commented Dec 11, 2018 at 13:22

1 Answer 1

3
$\begingroup$

It seems Row in TextCell can't have a second argument if you want it to behave correctly. That usage is mentioned in details and options section. Let's add Riffle:

TextCell[
  Row @ 
  Riffle[#, " "]& @ 
  MapAt[
    Style[#, Bold, 24, Red] &, 
    text, 
    {{21 ;; 31}, {54}, {60 ;; 80}}
  ], 
 TextJustification -> 1, 
 LineIndent->0
 ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.