LAGOS, Jan 24 (Reuters) - With Africa's most populous country out of recession, and the wider region on the path to growth, the world's consumer goods companies are looking to cash in.

Last month, Unilever opened a $12 million Blue Band margarine factory in Nigeria's southwestern state of Ogun so that it does not have to import margarine from Ghana, as it has in recent years. It is also in talks with suppliers to switch to a locally-sourced flavouring agent for its toothpaste.

These are examples of how the Anglo-Dutch group, like its global rivals, has been forced to adapt its business to cope with a central bank decision to restrict access to foreign currency for the import of certain products since 2015 to boost the economy.

Another way Unilever is tailoring its operations to the local market is by offering smaller pack sizes of a range of products to appeal to more customers in a country and region plagued by poverty and inequality.

Shops in Nigeria's commercial capital Lagos sell packets containing just two Unilever-produced tea bags or two stock cubes, for example. "These are all packs that we use to gain penetration and to develop the market," said Yaw Nsarkoh, managing director of Unilever Nigeria.

But again, the firm is not alone in such tactics; the same shops stock Nestle cereals ranging in size from 50 grams to 250 grams and 1 kilogram.

Britain's PZ Cussons meanwhile has rolled out a range of small pack sizes over the last three years for products from soap and detergent to milk and vegetable oil. "They have been popular and the biggest contributor in sales to each brand," said Christos Giannopoulos, CEO of the company's Nigerian business.

How best to navigate the African consumer market is on the agenda to be discussed by corporate leaders at the World Economic Forum in the Swiss resort of Davos this week.

The potential prize is alluring. It helps explains why these companies, plus the likes of Procter & Gamble, Diageo and Danone, have long operated in Nigeria and are willing to go to some lengths to build brands and market share.

The market is huge: Nigeria has about 190 million people, and that is expected to rise to 300 million by 2030 and 400 million by 2050, according to U.N. data, which would make it the world's third most populous country after China and India.

Companies are positioning themselves in the expectation that low household spending will rise as the economy grows and people come out of poverty and become consumers of packaged goods.

"If you look at the per capita consumption levels and the penetration levels of consumer categories in Nigeria generally, they are below many comparable markets," said Nsarkoh, pointing to India as an example.

EMERGING FROM DOWNTURN

But Nigeria and Sub-Saharan Africa has not been the mecca some envisioned. A continent-wide downturn since 2014, tied to low commodity prices, has dampened hopes for companies.

Net earnings of 28 consumer companies in nine African countries have grown just 2 percent per year in local currency in the five years to 2016, and even less in dollar terms, according to Exotix, an emerging markets-focused financial services firm.

But Nigeria, Africa's top oil producer, last year emerged from its first recession in 25 years which was largely caused by low crude prices. The World Bank sees the country's economy growing from 1 percent in 2017 to 2.5 percent this year.

Sub-Saharan Africa's economy is meanwhile projected to pick up this year, with the World Bank predicting growth of 3.2 percent in 2018 and 3.5 percent in 2019, up from 2.4 percent in 2017, due to firmer commodity prices.

In Nigeria, doing business has been particularly tough since 2015, when the foreign exchange curbs and the devaluation of the naira currency meant the cost of importing certain goods, which the government wanted to be grown locally, increased markedly.

However Unilever Nigeria's financial results suggest that some of the tactics adopted to counter this may be paying off.

Its operating profit almost tripled to 9.2 billion naira ($30.1 million) in the first nine months of 2017, the latest figures available, after growing 25 percent in 2016. Before that, profits were flat in 2015 and fell 40 percent in 2014. Fola Abimbola, an analyst at Nigerian bank FCMB, credited the latest profit rise to price increases, taken to offset the impact of currency devaluation, as well as the use of smaller pack sizes.

"All of these companies have been selling smaller packs because, during the recession, people have less money to spend. People opt for smaller packs," said Abimbola.

The use of smaller packaging is not new in emerging markets, but industry experts say that in Sub-Saharan Africa, it has not yet been widely adopted beyond the beer industry, and expect it to catch on further in coming years.

MAIZE, MILLET, PALM OIL

Unilever's Nsarkoh said 90 percent of its Nigerian goods were now manufactured locally, up from 80 percent about three years ago, to make its business more resilient. As well as margarine, locally-made products include soap, tea and toothpaste.

In a sprawling manufacturing plant in the bustling Ikeja district of Lagos, for example, Unilever workers clad in white lab coats oversee production lines capable of producing hundreds of tubes of Close-Up toothpaste a minute.

Among rivals, Swiss group Nestle said that 41,600 local farmers suppled maize, soybean, sorghum and millet to its Nigerian factories. It said 82 percent of its inputs were sourced locally and that it aimed to extend to 100 percent where possible. It cited Golden Morn cereal, made from maize farmed in the northwestern state of Kaduna, as a product in which the goal had been achieved.

PZ Cussons meanwhile has a stake in a 26,000-hectare palm oil plantation in the state of Cross River. Half of its vegetable oil is made using local palm oil, said Giannopoulos.