LaTeX forum ⇒ Graphics, Figures & TablesCustomize uparrow and downarrow Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
bstex
Posts: 65
Joined: Mon Oct 23, 2017 10:22 am

Customize uparrow and downarrow

Postby bstex » Thu Jun 21, 2018 5:57 pm

Hi.
I'm using the mhchem package and I'd like to have custom arrows in my text.
Rightarrow, leftarrow and doublearrow are fine with my custom design, but why uparrow and downarrow are not shown with my custom design?
Screen Shot 2018-06-21 at 18.55.57.png
Screen Shot 2018-06-21 at 18.55.57.png (13.93 KiB) Viewed 348 times

My MWE:
  1. \documentclass[a4paper,11pt]{book}
  2. \usepackage{tikz}
  3. \usetikzlibrary{positioning,arrows.meta}
  4. \usepackage[version=4]{mhchem}
  5.  
  6. \begin{document}
  7.  
  8. \ExplSyntaxOn
  9. \cs_set:Npn \__mhchem_arrow_options_minLength:n { {1.25em} }
  10. \ExplSyntaxOff
  11.  
  12. \mhchemoptions{arrows=pgf{Straight Barb[round, angle=60:1.5pt 3]}{0.1ex}}
  13. \ce{A -> B} \\
  14. \ce{C <- D} \\
  15. \ce{E <=> F} \\
  16. \ce{G ^} \\
  17. \ce{H v} \\
  18.  
  19. \end{document}

Thank you very much.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9020
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Jun 23, 2018 1:52 pm

mhchem does the customization only for horizontal arrows.

Here is a quick idea, taking the customized arrows and rotating them:

  1. \renewcommand{\uparrow}{\raisebox{0.3ex}{\rotatebox[origin=c]{90}{\ce{->}}}}
  2. \renewcommand{\downarrow}{\raisebox{0.3ex}{\rotatebox[origin=c]{-90}{\ce{->}}}}


mhchem.png
mhchem.png (10.13 KiB) Viewed 309 times


Stefan
Site admin

bstex
Posts: 65
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Sat Jun 23, 2018 3:07 pm

Pretty good, but this way the uparrow and downarrow have a little bit larger length than they should.
Screen Shot 2018-06-23 at 16.05.12.png
Screen Shot 2018-06-23 at 16.05.12.png (8.74 KiB) Viewed 306 times

Since the length of the arrows is defined in preamble with:
  1. \ExplSyntaxOn
  2. \cs_set:Npn \__mhchem_arrow_options_minLength:n { {1.25em} }
  3. \ExplSyntaxOff

is it possible to make shorter only the up and down arrows?
Thank you Stefan for your reply.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9020
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Jun 23, 2018 3:36 pm

The arrow could be scaled so it has the same proportions as the horizontal one:

  1. \renewcommand{\uparrow}{\scalebox{0.68}{\raisebox{0.75ex}{\rotatebox[origin=c]{90}{\ce{->}}}}}
  2. \renewcommand{\downarrow}{\scalebox{0.66}{\raisebox{0.78ex}{\rotatebox[origin=c]{-90}{\ce{->}}}}}



Stefam
Site admin

bstex
Posts: 65
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Sat Jun 23, 2018 3:42 pm

That's a solution, sure, but I need to shorten only the length of the arrow, not to shrink it.
Thank you again.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9020
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Jun 23, 2018 5:45 pm

Ok...

  1. \ExplSyntaxOn
  2. \renewcommand \uparrow {
  3. \raisebox {0.4ex} {
  4. \rotatebox [origin=c] {90} {
  5. \cs_set:Npn \__mhchem_arrow_options_minLength:n { {0.85em} }
  6. \ce{->}}}
  7. }
  8. \renewcommand \downarrow {
  9. \raisebox {0.4ex} {
  10. \rotatebox [origin=c] {-90} {
  11. \cs_set:Npn \__mhchem_arrow_options_minLength:n { {0.85em} }
  12. \ce{->}}}
  13. }
  14. \ExplSyntaxOff


mhchem-arrows.png
mhchem-arrows.png (10.54 KiB) Viewed 300 times


Stefan
Site admin

bstex
Posts: 65
Joined: Mon Oct 23, 2017 10:22 am

Postby bstex » Sun Jun 24, 2018 11:29 am

Oh, that was too complex for me to do.
Thank you very much, Stefan.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests