Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to use the lightning symbol but when I use it together with equations it becomes an ''E'' Why is that?

\documentclass[11pt,a4paper,oneside]{report} 
\usepackage[pdftex]{graphicx} 
\usepackage[T1]{fontenc} 
\usepackage{fouriernc}
\usepackage{mathtools}
\usepackage{amsfonts,amsmath,amssymb,amsthm} 
\usepackage[a4paper, hmargin={3.5cm,3cm}, vmargin={2.5cm,2.5cm}]{geometry} %margin
\usepackage{multicol}
\usepackage{enumerate}
\usepackage{ marvosym }


\begin{document}
\Lightning
but when used in an equation environment it becomes ''E''
\begin{equation}
\Lambda\gamma \Lightning
\end{equation}
\end{document}

the output enter image description here

What can be done to use \Lightning in equations? Thank you

share|improve this question
    

2 Answers 2

up vote 8 down vote accepted

To instruct LaTeX to treat \Lightning as a text-mode rather than as a math-mode macro, you could type either

\mbox{\Lightning}

or (since you're already loading the amsmath package)

\text{\Lightning}

for all math-mode occurrences of this macro.


Addendum: As @egreg has pointed out in a comment, a key issue (bug?) is that the file marvosym.sty provides the instruction

\newcommand{\mvchr}[1]{{\mvs\char#1}}

This macro assumes (implicitly) that the symbols of the marvosym package will only ever be used in text mode. By redefining this macro via

\renewcommand{\mvchr}[1]{\mbox{\mvs\symbol{#1}}}

in the preamble (after loading the marvosym package, of course), the behavior of this macro is modified globally and it's no longer necessary to encase any of the many individual macros of the marvosym package in \mbox wrappers.

share|improve this answer
    
It solves the problem nicely! Thank you. –  user124471 Aug 29 at 7:45
3  
A different strategy could be \renewcommand{\mvchr}[1]{\mbox{\mvs\symbol{#1}}} (or \text instead of \mbox with amsmath). This is what \mvchr should do to begin with. –  egreg Aug 29 at 9:01

Just in order to show some more ways to get a lightning symbol (the answer to your problem has been given in Micos answer and in the referenced questions in my comment):

% arara: lualatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{marvosym}
\let\marvosymLightning\Lightning
\usepackage{wasysym}
\let\wasysymLightning\lightning
\usepackage{stmaryrd}
\let\stmaryrdLightning\lightning
\usepackage{ulsy}
\let\ulsyLightning\blitza
% just for the last two lines:
\usepackage{fontspec}

\begin{document}
\[\text{\marvosymLightning}\text{\wasysymLightning}\stmaryrdLightning\text{\ulsyLightning}\]
% Lua- or XeLaTeX needed for the following example:
Unicode symbol \texttt{U+26A1} "High Voltage" and  \texttt{U+2607} "Lightning"
\setmainfont{DejaVuSans.ttf}
\[\text{\symbol{"26A1}\symbol{"2607}}\]
\end{document}

If you comment out the last package and the last two lines in the document, you may compile with PDFLaTeX as well. I just wanted to show the two unicode symbols I found for lightnings and how you could access them.

enter image description here

Or you use the package fontawesome:

% arara: lualatex

\documentclass{article}
\usepackage{mathtools}
\usepackage{fontawesome}

\begin{document}
\[\text{\faBolt}\]
\end{document}

enter image description here

share|improve this answer
    
Beautiful. I did not know you could change their sizes and make them bold as well. Great tips. Thank you –  user124471 Aug 30 at 9:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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