diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,12 @@
 
 # Changelog by versions
 
+## From 3.17.1.0 to 3.17.2.0
+
+* Semigroup instance for LaTeX.
+* Data, Generic, and Typeable instances for LaTeX
+* and related types.
+
 ## From 3.17.0.0 to 3.17.1.0
 
 * New math space commands (romildo).
diff --git a/HaTeX.cabal b/HaTeX.cabal
--- a/HaTeX.cabal
+++ b/HaTeX.cabal
@@ -1,5 +1,5 @@
 Name: HaTeX
-Version: 3.17.1.0
+Version: 3.17.2.0
 Author: Daniel Díaz
 Category: LaTeX
 Build-type: Simple
diff --git a/Text/LaTeX/Base/Syntax.hs b/Text/LaTeX/Base/Syntax.hs
--- a/Text/LaTeX/Base/Syntax.hs
+++ b/Text/LaTeX/Base/Syntax.hs
@@ -1,5 +1,5 @@
 
-{-# LANGUAGE CPP, DeriveDataTypeable #-}
+{-# LANGUAGE CPP, DeriveDataTypeable, DeriveGeneric #-}
 
 -- | LaTeX syntax description in the definition of the 'LaTeX' datatype.
 --   If you want to add new commands or environments not defined in
@@ -29,11 +29,16 @@
 import Data.Text (Text,pack)
 import qualified Data.Text
 import Data.Monoid
+#if MIN_VERSION_base(4,9,0)
+import qualified Data.Semigroup as Semigroup
+#endif
 import Data.String
 import Control.Applicative
 import Control.Monad (replicateM)
 import Data.Functor.Identity (runIdentity)
+import Data.Data (Data)
 import Data.Typeable
+import GHC.Generics (Generic)
 import Test.QuickCheck
 
 -- | Measure units defined in LaTeX. Use 'CustomMeasure' to use commands like 'textwidth'.
@@ -51,11 +56,11 @@
  | Ex Double -- ^ The height of an \"x\" in the current font.
  | Em Double -- ^ The width of an \"M\" in the current font.
  | CustomMeasure LaTeX -- ^ You can introduce a 'LaTeX' expression as a measure.
-   deriving (Eq, Show)
+   deriving (Data, Eq, Generic, Show, Typeable)
 
 -- | Different types of syntax for mathematical expressions.
 data MathType = Parentheses | Square | Dollar
-  deriving (Eq,Show)
+  deriving (Data, Eq, Generic, Show, Typeable)
 
 -- | Type of @LaTeX@ blocks.
 data LaTeX =
@@ -78,7 +83,7 @@
                       -- Use '<>' preferably.
  | TeXEmpty -- ^ An empty block.
             -- /Neutral element/ of '<>'.
-   deriving (Eq,Show,Typeable)
+   deriving (Data, Eq, Generic, Show, Typeable)
 
 -- | An argument for a 'LaTeX' command or environment.
 data TeXArg =
@@ -89,7 +94,7 @@
  | MSymArg [LaTeX] -- ^ Version of 'SymArg' with multiple options.
  | ParArg LaTeX    -- ^ An argument enclosed between @(@ and @)@.
  | MParArg [LaTeX] -- ^ Version of 'ParArg' with multiple options.
-   deriving (Eq,Show)
+   deriving (Data, Eq, Generic, Show, Typeable)
 
 -- Monoid instance for 'LaTeX'.
 
@@ -109,6 +114,11 @@
 -- | Alias for 'mappend'.
 (<>) :: Monoid a => a -> a -> a
 (<>) = mappend
+#endif
+
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup.Semigroup LaTeX where
+  (<>) = mappend
 #endif
 
 -- | Method 'fromString' escapes LaTeX reserved characters using 'protectString'.
diff --git a/Text/LaTeX/Base/Writer.hs b/Text/LaTeX/Base/Writer.hs
--- a/Text/LaTeX/Base/Writer.hs
+++ b/Text/LaTeX/Base/Writer.hs
@@ -192,11 +192,11 @@
  return p
 
 -- | A helper function for building monad transformers, e.g.
--- @@
---       instance MonadReader r m => MonadReader r (LaTeXT m) where
---         ask = lift ask
---         local = mapLaTeXT . local
--- @@
+--
+-- > instance MonadReader r m => MonadReader r (LaTeXT m) where
+-- >   ask = lift ask
+-- >   local = mapLaTeXT . local
+--
 -- This declaration could be included here, but it would add a
 -- dependency on mtl.
 mapLaTeXT :: (m (a, LaTeX) -> m (a, LaTeX)) -> LaTeXT m a -> LaTeXT m a
