Headers in sub-documents

I am working with a master document and sub-documents with LibreOffice Writer. Each sub-document has a different header, but in the master document all the sub-documents have the header of the first sub-document. How do I preserve the distinct headers of the sub-documents in the master document?

Should the headers repeat subdocument name or something?

Yes, I want the header of each sub-document to have the name of that sub-document.

The content of the header is part of the page style. To get different texts into the header you can use things you get under Insert > Fields > Other… > Document (e.g. page number, chapter) [see comment of mahfiaz]. Or you use different page styles for your sub documents. That will generate a page break in the master document, so that your subdocument starts on a new page with its own header.

I used a unique page style for each sub-document, and this worked, as long as I only had a single page style in each sub-document. Thanks.