McGraw-Hill and Cengage plan to merge in a deal that would create the second-largest provider of college textbooks and other higher-education materials in the country.

The closely held companies, formally known as McGraw-Hill Education Inc. and Cengage Learning Holdings II Inc., are billing the all-stock deal as a rare merger of equals, which would set them up to better compete as the rise of digital books and course materials pressures their businesses.

The...