def merge(self, *, config: Config | None = None, **kwargs) -> Config:
        """Merge configuration based on old configuration and field values.

        Args:
            config: If None, the merged one will merge defaults and field values,
                instead of merging old configuration and field values.
            **kwargs: Members to modify. This value precedes both self and config.

        Returns:
            A new Config object
        """

        def merge_field(name: str) -> Any:
            # Precedence: kwargs -> config -> self
            arg = kwargs.get(name)
            if arg is None:
                if config is not None:
                    arg = getattr(config, name)
                else:
                    arg = getattr(self, name)
            return arg

        return Config(**{f.name: merge_field(f.name) for f in dataclasses.fields(self)})
Merge configuration based on old configuration and field values.

        Args:
            config: If None, the merged one will merge defaults and field values,
                instead of merging old configuration and field values.
            **kwargs: Members to modify. This value precedes both self and config.

        Returns:
            A new Config object
        
src/latexify/config.py